commit | f29d10eb491c074288da02800f6a3637b87d86cb | [log] [tgz] |
---|---|---|
author | android-build-team Robot <android-build-team-robot@google.com> | Fri Sep 18 01:11:35 2020 +0000 |
committer | android-build-team Robot <android-build-team-robot@google.com> | Fri Sep 18 01:11:35 2020 +0000 |
tree | 61f8cf9de82b1871077110126fbb23316afbde28 | |
parent | b2af497b2356032a6abb3601d3690ad539e42a5e [diff] | |
parent | cbb466efc6aba87ff4fde376c5fcfe04468ee201 [diff] |
Snap for 6845284 from cbb466efc6aba87ff4fde376c5fcfe04468ee201 to sc-release Change-Id: I20fdd9497e70ce579b16c3e2e4f3df80de93ef6b
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.