#serde-default #annotations #extend

macro smart-serde-default

An annotation to implement #[serde(default)] and Default

1 unstable release

0.1.1 Jun 21, 2024
0.1.0 Jun 21, 2024

#698 in Procedural macros

Download history 2/week @ 2024-12-04 3/week @ 2024-12-11 19/week @ 2025-01-15 9/week @ 2025-01-22 27/week @ 2025-01-29

55 downloads per month

MIT/Apache

6KB
56 lines

smart-serde-default

License Contributors GitHub Repo stars crates.io

A crate that basically extends the serde-inline-default and smart-default crates functionality to allow you to specify a default for both std::default::Default and serde with one annotation.

Documentation

Defining defaults

#[smart_serde_default]
#[derive(Debug, Deserialize, Serialize, SmartDefault)]
pub struct FuzionRedisConfigBuilder {
  #[smart_default(String::from("127.0.0.1"))]
  host: String,

  #[smart_default(6379)]
  port: u16,
}

Dependencies

~190–620KB
~15K SLoC