#structures #macro #derive-debug

macro general-structs

General-structures - this library allows you to create structures with common fields, and those that are different can be specified individually

2 unstable releases

0.2.0 May 28, 2024
0.1.0 May 27, 2024

#670 in Procedural macros

41 downloads per month

Apache-2.0

8KB
109 lines

General-structs

general-structures - this library allows you to create structures with common fields, and those that are different can be specified individually.

Example

general_structs! {
    #[derive(Debug, Clone, Copy)]
    struct Foo1 + Foo2<T> + Foo3 {
        bar1: f32,
        pub bar2: usize,
    }

    Foo2<T> {
        generic_bar: T
    }
}

Result:

#[derive(Debug, Clone, Copy)]
struct Foo1 {
    bar1: f32,
    pub bar2: usize,
}

#[derive(Debug, Clone, Copy)]
struct Foo2<T> {
    bar1: f32,
    pub bar2: usize,
    generic_bar: T
}
    
#[derive(Debug, Clone, Copy)]
struct Foo3 {
    bar1: f32,
    pub bar2: usize,
}

Dependencies

~240–690KB
~16K SLoC