einstellung_derive 0.1.6

Proc-Macro crate for einstellung
Documentation
---
source: einstellung_derive/src/test.rs
expression: formatted
---
/// --- input ---
#[derive(Config)]
struct Config {
    #[config(partial(serde(rename = "field")))]
    x: Vec<u32>,
}

/// --- output ---
#[derive(::core::default::Default, ::einstellung::serde::Deserialize)]
#[serde(crate = "::einstellung::serde")]
struct ConfigPartial {
    #[serde(rename = "field")]
    x: ::core::option::Option<Vec<u32>>,
}
#[automatically_derived]
impl ::einstellung::PartialConfig for ConfigPartial {
    type Complete = Config;
    fn merge(
        self,
        next: Self,
    ) -> ::core::result::Result<Self, ::einstellung::ConfigError> {
        ::core::result::Result::Ok(Self { x: next.x.or(self.x) })
    }
    fn build(
        self,
    ) -> ::core::result::Result<Self::Complete, ::einstellung::ConfigError> {
        ::core::result::Result::Ok(Config {
            x: self
                .x
                .ok_or(
                    ::einstellung::ConfigError::MissingField(
                        ::einstellung::FieldPath::new("Config", "x"),
                    ),
                )?,
        })
    }
}
#[automatically_derived]
impl ::einstellung::Config for Config {
    type Partial = ConfigPartial;
}