8000 GitHub - evnu/multi-structs: Macro for generating a merged struct from multiple sub-structs
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

evnu/multi-structs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Macro for generating a merged struct from multiple sub-structs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%
0