multi-structs
A macro for generating a merged struct from multiple sub-structs.
Example
#[macro_use]
extern crate multi_structs;
multi_structs! {
#[derive(Debug)]
pub struct Merged {
#[derive(Debug)]
pub foo: struct Foo {
pub a: i32,
pub b: i64,
}
#[derive(Debug)]
pub bar: struct Bar {
pub c: usize,
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);
}