commit | a419437bc9360dafcd1eb2a787647dc3184a14a7 | [log] [tgz] |
---|---|---|
author | Matthew Maurer <[email protected]> | Thu Mar 09 18:06:13 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Mar 09 18:06:13 2023 +0000 |
tree | 4d02240b6a356275f2e27bd9fea034214dd6efe0 | |
parent | cb4c9d0fe5fd8d3c8cb454fe265a22bea28cdc19 [diff] | |
parent | 99b88e44efed24f28565d9a487d5560050359095 [diff] |
Make num-derive available to product and vendor am: 578c2b6ca3 am: fef27ce304 am: a5d61d2627 am: 99b88e44ef Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/num-derive/+/2476388 Change-Id: Ib4e8477da68086e95a1b4301534cda9448f22e48 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.