#derive #macro #plugin #macro1-1

macro derivative

A set of alternative derive attributes for Rust

10 releases (3 stable)

1.0.2 Nov 7, 2018
1.0.1 Oct 20, 2018
1.0.0 Feb 2, 2017
0.3.1 Jan 21, 2017
0.0.3 Oct 12, 2016

#18 in Rust patterns

Download history 2685/week @ 2019-03-28 3645/week @ 2019-04-04 4713/week @ 2019-04-11 4904/week @ 2019-04-18 4299/week @ 2019-04-25 3863/week @ 2019-05-02 3913/week @ 2019-05-09 4404/week @ 2019-05-16 4320/week @ 2019-05-23 4209/week @ 2019-05-30 4965/week @ 2019-06-06 6164/week @ 2019-06-13 6064/week @ 2019-06-20 6510/week @ 2019-06-27 6537/week @ 2019-07-04

16,105 downloads per month
Used in 221 crates (49 directly)

MIT/Apache

68KB
1.5K SLoC

Derivative Travis Build status Crates.io Crates.io

This crate provides a set of alternative #[derive] attributes for Rust.

Documentation

Stability

This crate is now stable and usable on rustc stable too!

Note that you need rustc 1.15 or later.

What it does

#[derive(Derivative)]
#[derivative(Debug)]
struct Foo {
    foo: u8,
    #[derivative(Debug="ignore")]
    bar: u8,
}

println!("{:?}", Foo { foo: 42, bar: 1 }); // Foo { foo: 42 }

Check the documentation for more!

License

Licensed under either of

at your option.

Acknowledgements

This is inspired from how serde wonderfully handles attributes. This also takes some code and ideas from serde itself.

Some tests are directly adapted from rustc's tests.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2MB
~41K SLoC