commit | 90214ebdd7e8843bdea7c5047ea3ff41ad033a45 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sat Nov 11 04:13:01 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sat Nov 11 04:13:01 2023 +0000 |
tree | 7af162db7ed50bc535901cb51ec5c4bd9b9c3ec7 | |
parent | f8ece0a21e1c79286f0d3c7866f16f7385e45140 [diff] | |
parent | 6acf04bb2e23da386651bf4b2491f46b74836fa3 [diff] |
Snap for 11085410 from 6acf04bb2e23da386651bf4b2491f46b74836fa3 to 24D1-release Change-Id: Id5071bca341b242c7ffe44fdee8e71cca5952377
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.