#struct #field #struct-fields #properties #partial #derive #optional

macro partial_derive

makes all the properties of a struct type an optional property

1 unstable release

0.1.0 Mar 21, 2022

#58 in #partial

MIT license

5KB
75 lines

partial_derive

Like Partial<T> of TypeScript, makes all the properties of a struct type an optional property.

Provides Partial derive macro.

#[derive(Partial)]
#[derive(Clone)]
struct SomeStruct {
    pub field_one: i32,
    field_two: Vec<bool>,
}

generates

#[derive(Clone)]
struct PartialSomeStruct {
    pub field_one: Option<i32>,
    field_two: Option<Vec<bool>>,
}

Dependencies

~1.5MB
~33K SLoC