commit | 63e3350576163857d64193532b4f04743db8237d | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Sat Oct 10 01:10:36 2020 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Sat Oct 10 01:10:36 2020 +0000 |
tree | fe685f62dad88790e374a48934534d4517add021 | |
parent | cfd63fb88ba3def46748f1ff8bea5e94216f0539 [diff] | |
parent | e6ce4232ca332ecc0e0b00a0d28ecf77b47350c5 [diff] |
Snap for 6896080 from e6ce4232ca332ecc0e0b00a0d28ecf77b47350c5 to sc-release Change-Id: I889cc0d79298495ceb229d6193fa9a599917bdca
Procedural macros to derive numeric traits in Rust.
Add this to your Cargo.toml
:
[dependencies] num-traits = "0.2" num-derive = "0.3"
and this to your crate root:
#[macro_use] extern crate num_derive;
Then you can derive traits on your own types:
#[derive(FromPrimitive, ToPrimitive)] enum Color { Red, Blue, Green, }
full-syntax
— Enables num-derive
to handle enum discriminants represented by complex expressions. Usually can be avoided by utilizing constants, so only use this feature if namespace pollution is undesired and compile time doubling is acceptable.Release notes are available in RELEASES.md.
The num-derive
crate is tested for rustc 1.31 and greater.