deep_causality_macros

Crates.iodeep_causality_macros
lib.rsdeep_causality_macros
version0.4.10
sourcesrc
created_at2023-06-26 12:02:25.722915
updated_at2024-11-24 11:52:49.137842
descriptionProcedural macros that generate constructurs and getters.
homepage
repositoryhttps://github.com/deepcausality/deep_causality.rs
max_upload_size
id900286
size36,495
Marvin Hansen (marvin-hansen)

documentation

https://docs.rs/deep_causality

README

Macros

Crates.io Docs.rs MIT licensed Audit Clippy Tests

🤔 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
Commit count: 1107

cargo fmt