commit | 83225e818a07bf4179afec4e0a96da52340bfcfd | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Feb 02 02:28:27 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Feb 02 02:28:27 2023 +0000 |
tree | ce8936c4d32f4ddfa646fccf158fd64bb1d446c9 | |
parent | 127bdb7871fef141fcd473cc9adb6c0bea2af199 [diff] | |
parent | cb4c9d0fe5fd8d3c8cb454fe265a22bea28cdc19 [diff] |
Snap for 9552483 from cb4c9d0fe5fd8d3c8cb454fe265a22bea28cdc19 to udc-release Change-Id: Ia7c82e95968a76d2b7201b89130af0ca4cfe9638
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.
Licensed under either of
at your option.
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.