#traits #basic #proc-macro #impls #deriving #natural #derive

macro natural-derive

Proc macros for naturally deriving basic trait impls for new types

4 releases (2 breaking)

0.4.0 Jan 25, 2023
0.3.1 Jan 9, 2023
0.3.0 Dec 23, 2022
0.1.0 Dec 23, 2022

#1397 in Procedural macros

Apache-2.0

13KB
287 lines

natural-derive

Proc macros for naturally deriving basic trait impls for new types, i.e. respecting the structure and semantics of the inner type.

Example

use natural_derive::Add;

#[derive(Debug, PartialEq, Eq, Add)]
struct Kelvin(u32);

fn main() {
    let kelvin = Kelvin(42) + Kelvin(1);
    assert_eq!(kelvin, Kelvin(43));
}

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License

This code is open source software licensed under the Apache 2.0 License.

Dependencies

~1.5MB
~37K SLoC