commit | c210b33ee6c2a8156e8573a90260a5568a19e94f | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Fri Mar 10 04:18:44 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Fri Mar 10 04:18:44 2023 +0000 |
tree | 4d02240b6a356275f2e27bd9fea034214dd6efe0 | |
parent | 83225e818a07bf4179afec4e0a96da52340bfcfd [diff] | |
parent | 727135ccdff286ed4d3d71b50b4b9ce7ee2d517d [diff] |
Snap for 9719949 from 99b88e44efed24f28565d9a487d5560050359095 to udc-release am: 727135ccdf Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/num-derive/+/21946598 Change-Id: Ia3514a55c62a8edfd9ea8a85d58f381908200908 Signed-off-by: Automerger Merge Worker <[email protected]>
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.