#optional #macro-derive #properties #struct #partial #clone #typescript

partial_derive2

makes all the properties of a struct type an optional property

12 releases

new 0.3.2 Apr 28, 2024
0.3.1 Apr 28, 2024
0.2.2 Mar 27, 2024
0.2.1 Jul 12, 2023
0.1.4 Jun 14, 2023

#979 in Rust patterns

Download history 9/week @ 2024-01-14 10/week @ 2024-01-21 8/week @ 2024-02-04 29/week @ 2024-02-18 25/week @ 2024-02-25 2/week @ 2024-03-10 13/week @ 2024-03-17 109/week @ 2024-03-24 36/week @ 2024-03-31 36/week @ 2024-04-07 6/week @ 2024-04-14 21/week @ 2024-04-21

109 downloads per month

MIT license

5KB
58 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, Clone)]
#[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

~285–730KB
~17K SLoC