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

#1286 in Procedural macros

Download history 38/week @ 2023-10-29 19/week @ 2023-11-05 39/week @ 2023-11-12 39/week @ 2023-11-19 54/week @ 2023-11-26 11/week @ 2023-12-03 14/week @ 2023-12-10 26/week @ 2023-12-17 35/week @ 2023-12-24 31/week @ 2023-12-31 26/week @ 2024-01-07 51/week @ 2024-01-14 44/week @ 2024-01-21 46/week @ 2024-01-28 18/week @ 2024-02-04 62/week @ 2024-02-11

172 downloads per month
Used in 2 crates

MIT license

23KB
527 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

~330–770KB
~19K SLoC