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

partial_derive2

makes all the properties of a struct type an optional property

14 unstable releases (3 breaking)

new 0.4.1 May 9, 2024
0.4.0 May 8, 2024
0.3.2 Apr 28, 2024
0.2.2 Mar 27, 2024
0.1.4 Jun 14, 2023

#1483 in Rust patterns

Download history 14/week @ 2024-01-18 3/week @ 2024-01-25 2/week @ 2024-02-01 6/week @ 2024-02-08 5/week @ 2024-02-15 36/week @ 2024-02-22 13/week @ 2024-02-29 1/week @ 2024-03-07 6/week @ 2024-03-14 79/week @ 2024-03-21 66/week @ 2024-03-28 28/week @ 2024-04-04 20/week @ 2024-04-11 15/week @ 2024-04-18 329/week @ 2024-04-25 67/week @ 2024-05-02

437 downloads per month

MIT license

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

~315–770KB
~18K SLoC