commit | f749fccf68c6fea18035046112d9367e087a2f8e | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sat Nov 11 02:12:51 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sat Nov 11 02:12:51 2023 +0000 |
tree | 7af162db7ed50bc535901cb51ec5c4bd9b9c3ec7 | |
parent | f8ece0a21e1c79286f0d3c7866f16f7385e45140 [diff] | |
parent | 6acf04bb2e23da386651bf4b2491f46b74836fa3 [diff] |
Snap for 11084970 from 6acf04bb2e23da386651bf4b2491f46b74836fa3 to 24Q1-release Change-Id: I4c4bc3355508d36a8bc6e9b1c376bdd51a8a2288
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.