Crates.io | deep_causality_macros |
lib.rs | deep_causality_macros |
version | 0.4.8 |
source | src |
created_at | 2023-06-26 12:02:25.722915 |
updated_at | 2023-09-19 03:49:01.588036 |
description | Procedural macros that generate constructurs and getters. |
homepage | |
repository | https://github.com/deepcausality/deep_causality.rs |
max_upload_size | |
id | 900286 |
size | 29,194 |
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.
Just run:
cargo add deep_causality_macros
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);
}
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.
This project is licensed under the MIT license.
For details about security, please read the security policy.