Expand description
Proc macro crate: Partial derive
Derive Partial on a struct Foo to generate a new struct named FooPartial
where every field type is wrapped in Option<T> unless it is already an Option<T>.
Only structs with named fields are accepted; tuple and unit structs are not supported yet.
Example:
ⓘ
#[optifier::partial_derive(Debug, Clone)]
#[derive(optifier::Partial)]
pub struct Foo {
a: i32,
b: Option<String>,
pub c: Vec<u8>,
}expands to:
ⓘ
#[derive(Debug, Clone)]
pub struct FooPartial {
a: Option<i32>,
b: Option<String>, // stays as-is
pub c: Option<Vec<u8>>,
}The #[optifier::partial_derive(...)] attribute controls which traits are derived for the
generated *Partial type. It accepts a comma-separated list of trait paths.
Attribute Macros§
- partial_
derive - Attribute macro to configure derives for the generated
*Partialtype.
Derive Macros§
- Partial
- Derive macro to generate a
*Partialvariant of a struct with all fields wrapped inOption.