multi-structs 0.1.1

Macro for generating a merged struct from multiple sub-structs
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented1 out of 6 items with examples
  • Size
  • Source code size: 7.71 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.68 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • upsuper/multi-structs
    3 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • upsuper

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);
}