Optifier
Proc macro crate: Partial derive
[!note] This crate is early development phase. I use it only in my personal projects and update it as needed.
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:
use optifier;
expands to:
#[optifier::partial_derive(...)] attribute
The #[optifier::partial_derive(...)] attribute configures which traits are derived
for the generated *Partial type.
- It is applied to the original struct, together with
#[derive(optifier::Partial)]. - It accepts a comma-separated list of trait paths (e.g.
Debug,Clone,PartialEq, or fully qualified paths). - Whatever traits you list there are emitted as a
#[derive(...)]on the generated<OriginalName>Partialtype.
Example:
use optifier;
generates roughly: