3 releases (breaking)

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

#11 in #declare

43 downloads per month

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

~0.5–1MB
~21K SLoC