Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therustmonk/mixin
mixin macros
https://github.com/therustmonk/mixin
Last synced: 2 days ago
JSON representation
mixin macros
- Host: GitHub
- URL: https://github.com/therustmonk/mixin
- Owner: therustmonk
- Created: 2020-04-29T06:54:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T15:15:54.000Z (about 1 year ago)
- Last Synced: 2025-01-02T01:12:16.583Z (7 days ago)
- Language: Rust
- Size: 8.79 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
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");
}
```