-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
Consider this schema:
{
"$defs": {
"MaxPathConfig": {
"type": "integer",
"minimum": 1
},
"Thing": {
"type": "object",
"properties": {
"max_path": {
"default": 1,
"allOf": [
{
"$ref": "#/$defs/MaxPathConfig"
}
]
}
}
}
}
}This generates this code for Thing:
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Thing {
#[serde(default = "defaults::thing_max_path")]
pub max_path: MaxPathConfig,
}Looks good! However, here's the default mod:
#[doc = r" Generation of default values for serde."]
pub mod defaults {
pub(super) fn default_nzu64<T, const V: u64>() -> T
where
T: ::std::convert::TryFrom<::std::num::NonZeroU64>,
<T as ::std::convert::TryFrom<::std::num::NonZeroU64>>::Error: ::std::fmt::Debug,
{
T::try_from(::std::num::NonZeroU64::try_from(V).unwrap()).unwrap()
}
pub(super) fn thing_max_path() -> super::MaxPathConfig {
super::MaxPathConfig(::std::num::NonZeroU64::new(1).unwrap())
}
}Note that while thing_max_path is used, default_nzu64 is not and results in an unused code lint in generated code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels