macro_rules! config_field {
($t:ty) => { ... };
($t:ty, $arg:ident => $transform:expr) => { ... };
}
Expand description
Macro that generates ConfigField
for a given type.
§Usage
This always requires Display
to be implemented for the given type.
There are two ways to invoke this macro. The first one uses
default_config_transform
/FromStr
to parse the data:
ⓘ
config_field(MyType);
Note that the parsing error MUST implement std::error::Error
!
Or you can specify how you want to parse an str
into the type:
ⓘ
fn parse_it(s: &str) -> Result<MyType> {
...
}
config_field(
MyType,
value => parse_it(value)
);