#macro-derive #optional #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

#1166 in Rust patterns

Download history 58/week @ 2024-09-11 39/week @ 2024-09-18 80/week @ 2024-09-25 111/week @ 2024-10-02 95/week @ 2024-10-09 83/week @ 2024-10-16 77/week @ 2024-10-23 68/week @ 2024-10-30 31/week @ 2024-11-06 28/week @ 2024-11-13 65/week @ 2024-11-20 38/week @ 2024-11-27 40/week @ 2024-12-04 57/week @ 2024-12-11 29/week @ 2024-12-18

130 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

~215–660KB
~16K SLoC