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

partial_derive2

makes all the properties of a struct type an optional property

15 unstable releases (3 breaking)

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

#785 in Rust patterns

Download history 16/week @ 2024-01-20 1/week @ 2024-01-27 7/week @ 2024-02-03 1/week @ 2024-02-10 29/week @ 2024-02-17 24/week @ 2024-02-24 1/week @ 2024-03-02 2/week @ 2024-03-09 10/week @ 2024-03-16 102/week @ 2024-03-23 44/week @ 2024-03-30 37/week @ 2024-04-06 7/week @ 2024-04-13 20/week @ 2024-04-20 347/week @ 2024-04-27 474/week @ 2024-05-04

858 downloads per month

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

~320–770KB
~18K SLoC