commit | 1ce18cb90a5b011b80519224b82858b6338b846b | [log] [tgz] |
---|---|---|
author | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:40:57 2022 -0800 |
committer | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:40:57 2022 -0800 |
tree | 75f57a29ac6cac238a6e6aebb0f09f5d5c68f1a6 | |
parent | 26f8b076addc7d5aa6f5c5f35b1a14dae90faee7 [diff] | |
parent | f8e76af095df63885d3d095b3ee18b18014781f1 [diff] |
Merge f8e76af095df63885d3d095b3ee18b18014781f1 on remote branch Change-Id: I9294e77c0cec9ca915e9c168998608424293875a
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.