commit | 9c3306c57bc37243a5cb92dce15fd7db87bb43c2 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Jun 22 17:08:49 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Jun 22 17:08:49 2023 +0000 |
tree | 013695c6c3323ccdb9c6dccb7357753d563bcf9e | |
parent | 6ae2b5001ec44b3565b981b41ea05404d7a00c84 [diff] | |
parent | fd2dcef001300746d2f4d5ebe68453380c6fc03e [diff] |
Snap for 10363732 from fd2dcef001300746d2f4d5ebe68453380c6fc03e to emu-33-release Change-Id: Ie0ee1a3a9e0b9fdadcc469749da61284e81574c0
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.