commit | d75e44b4da488277a0621569e1dfc275e77e2c84 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sun Dec 17 02:17:44 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sun Dec 17 02:17:44 2023 +0000 |
tree | 7af162db7ed50bc535901cb51ec5c4bd9b9c3ec7 | |
parent | 8027fd8a0d4e999c79b5f359e10184703c526862 [diff] | |
parent | c8db8b1c6e6c17abaf361e57881d63fd92de08a0 [diff] |
Snap for 11228863 from c8db8b1c6e6c17abaf361e57881d63fd92de08a0 to emu-34-release Change-Id: I608f2a8dc8ce1f86ce6ad3801e9f8329e0995425
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.