commit | 6ae2b5001ec44b3565b981b41ea05404d7a00c84 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Fri Jun 02 01:28:36 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Fri Jun 02 01:28:36 2023 +0000 |
tree | 013695c6c3323ccdb9c6dccb7357753d563bcf9e | |
parent | d8fb7bfaeaa39b05b1b26e1c1e7e0b12405eb39c [diff] | |
parent | 559b5f310704d3d7fc82917b5d3c1189f8ec5f2d [diff] |
Snap for 10238332 from 559b5f310704d3d7fc82917b5d3c1189f8ec5f2d to emu-33-release Change-Id: If75b0042993af0ed89d53200be4b9f7960c402be
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.