#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

#405 in Procedural macros

24 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

~225–660KB
~16K SLoC