multi-structs

Crates.iomulti-structs
lib.rsmulti-structs
version0.1.1
sourcesrc
created_at2018-05-27 14:38:31.679586
updated_at2020-01-11 23:27:51.892194
descriptionMacro for generating a merged struct from multiple sub-structs
homepage
repositoryhttps://github.com/upsuper/multi-structs
max_upload_size
id67284
size8,081
Xidorn Quan (upsuper)

documentation

README

multi-structs

Build Status Docs

A macro for generating a merged struct from multiple sub-structs.

Example

#[macro_use]
extern crate multi_structs;

multi_structs! {
    /// The merged struct.
    #[derive(Debug)]
    pub struct Merged {
        /// Foo
        #[derive(Debug)]
        pub foo: struct Foo {
            /// a
            pub a: i32,
            /// b
            pub b: i64,
        }
        /// Bar
        #[derive(Debug)]
        pub bar: struct Bar {
            /// c
            pub c: usize,
            /// d
            pub d: String,
        }
    }
}

fn main() {
    let foo = Foo { a: 1, b: 2 };
    let bar = Bar { c: 3, d: "aaa".to_string() };
    println!("{:?}, {:?}", foo, bar);
    let merged = Merged::new(foo, bar);
    println!("{:?}", merged);
    let (foo, bar) = merged.split();
    println!("{:?}, {:?}", foo, bar);
}
Commit count: 11

cargo fmt