commit | 052a43e109ff61dc9ee8d0c6f2f5c237f8586f83 | [log] [tgz] |
---|---|---|
author | Linux Build Service Account <lnxbuild@localhost> | Sun Jan 16 14:30:20 2022 -0800 |
committer | Linux Build Service Account <lnxbuild@localhost> | Sun Jan 16 14:30:20 2022 -0800 |
tree | c9a58f4fc6663d85c63dcb9f4a8cf00c85f3993e | |
parent | be6bbc16974b0e752bf4baec9b5ac314ff885ba3 [diff] | |
parent | 1f4d15385154d731583d694a5b34b0f035fd5473 [diff] |
Merge 1f4d15385154d731583d694a5b34b0f035fd5473 on remote branch Change-Id: I89bf666b997e9cef54fa955979701b46cd451ff9
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.