9 releases
0.4.8 | Sep 19, 2023 |
---|---|
0.4.7 | Sep 6, 2023 |
0.4.6 | Aug 30, 2023 |
0.4.4 | Jul 7, 2023 |
0.4.1 | Jun 28, 2023 |
#1431 in Procedural macros
Used in 2 crates
23KB
527 lines
Macros
🤔 Why?
Write custom types with near-zero boilerplate code. Rust is great, but when you write a lot of custom types, adding constructor and getters becomes tedious. These macros solve this by generating the boilerplate code for you.
🎁 Features
- Generates default constructor for structs and enums
- Generates getters for structs
- Getters can be renamed
🚀 Install
Just run:
cargo add deep_causality_macros
⭐ Usage
See:
use deep_causality_macros::{Getters, Constructor};
#[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub struct Data<T>{
#[getter(name = data_id)] // Rename getter methods as you wish
id: u64,
data: T,
filled: bool,
}
pub fn main() {
let d = Data::new(0, 42, true);
assert_eq!(*d.data_id(), 0);
assert_eq!(*d.data(), 42);
assert_eq!(*d.filled(), true);
}
👨💻👩💻 Contribution
Contributions are welcomed especially related to documentation, example code, and fixes. If unsure where to start, open an issue and ask.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in deep_causality by you, shall be licensed under the MIT license without additional terms or conditions.
📜 Licence
This project is licensed under the MIT license.
👮️ Security
For details about security, please read the security policy.
💻 Author
- Marvin Hansen.
- Github GPG key ID: 369D5A0B210D39BC
- GPG Fingerprint: 4B18 F7B2 04B9 7A72 967E 663E 369D 5A0B 210D 39BC
Dependencies
~230–670KB
~16K SLoC