11 releases

0.4.10 Nov 24, 2024
0.4.9 Nov 21, 2024
0.4.8 Sep 19, 2023
0.4.6 Aug 30, 2023
0.4.1 Jun 28, 2023

#1501 in Procedural macros

Download history 7/week @ 2024-08-26 15/week @ 2024-09-23 5/week @ 2024-11-04 387/week @ 2024-11-18 112/week @ 2024-11-25

504 downloads per month
Used in 2 crates

MIT license

23KB
521 lines

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

Dependencies

~220–660KB
~16K SLoC