commit | 8765cee775ba30be14f8a38cea6be2b2d76b8381 | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Fri Sep 18 03:07:26 2020 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Fri Sep 18 03:07:26 2020 +0000 |
tree | 61f8cf9de82b1871077110126fbb23316afbde28 | |
parent | 5f4c0b58106403d979138e9396e266be77bfa371 [diff] | |
parent | a6d38d96dc2085667e926cd3a4a3e9e1735c5225 [diff] |
Snap for 6845596 from a6d38d96dc2085667e926cd3a4a3e9e1735c5225 to sc-d1-release Change-Id: Ideb182f4dcb0fa9e9019cafc65a61564c7a0c549
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.