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

partial_derive2

makes all the properties of a struct type an optional property

16 unstable releases (3 breaking)

0.4.3 Jun 8, 2024
0.4.2 May 10, 2024
0.3.2 Apr 28, 2024
0.2.2 Mar 27, 2024
0.1.4 Jun 14, 2023

#1091 in Rust patterns

Download history 51/week @ 2024-06-21 12/week @ 2024-06-28 49/week @ 2024-07-05 34/week @ 2024-07-12 13/week @ 2024-07-19 33/week @ 2024-07-26 37/week @ 2024-08-02 89/week @ 2024-08-09 75/week @ 2024-08-16 26/week @ 2024-08-23 48/week @ 2024-08-30 53/week @ 2024-09-06 42/week @ 2024-09-13 55/week @ 2024-09-20 86/week @ 2024-09-27 105/week @ 2024-10-04

295 downloads per month
Used in 4 crates (2 directly)

MIT license

6KB
92 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

~250–690KB
~17K SLoC