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

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

#1534 in Rust patterns

Download history 65/week @ 2025-07-16 103/week @ 2025-07-23 78/week @ 2025-07-30 101/week @ 2025-08-06 158/week @ 2025-08-13 151/week @ 2025-08-20 108/week @ 2025-08-27 106/week @ 2025-09-03 107/week @ 2025-09-10 132/week @ 2025-09-17 73/week @ 2025-09-24 84/week @ 2025-10-01 69/week @ 2025-10-08 72/week @ 2025-10-15 112/week @ 2025-10-22 47/week @ 2025-10-29

308 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

~165–580KB
~14K SLoC