3 releases (breaking)

0.2.0 Apr 30, 2020
0.1.0 Apr 30, 2020
0.0.0 Apr 29, 2020

#134 in #struct-fields


Used in ibkr_client_portal

MIT/Apache

8KB
129 lines

mixin macros

This crate contains mixin macros that combines fields and implementations of different structs.

Example:

#[mixin::declare]
pub struct Named {
    name: String,
}

#[mixin::expand]
impl Named {
    pub fn name(&self) -> &str {
        &self.name
    }
}

#[mixin::insert(Named)]
pub struct MyStruct {}

#[test]
fn test_it() {
    let my_struct = MyStruct { name: "MixIn Works" };
    assert_eq!(my_struct.name(), "MixIn Works");
}

Dependencies

~1.5MB
~40K SLoC