Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/therustmonk/mixin

mixin macros
https://github.com/therustmonk/mixin

Last synced: 2 days ago
JSON representation

mixin macros

Awesome Lists containing this project

README

        

# mixin macros

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

Example:

```rust
#[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");
}
```