commit | 99f94416de55d8e8c00efd03ffb4263bf2cc3517 | [log] [tgz] |
---|---|---|
author | Daniel Norman <danielnorman@google.com> | Mon Nov 30 11:41:50 2020 -0800 |
committer | Daniel Norman <danielnorman@google.com> | Mon Nov 30 11:41:50 2020 -0800 |
tree | 66333ecac74c5b21a5d6b4d4d2b354e4e7556c19 | |
parent | a0555b315af11ae4a6bd2bd2e3100af35e3c6dac [diff] | |
parent | 4850fb7d45f98c9497ab1b4d8c079fc973ebf6b7 [diff] |
Merge SP1A.201130.001 Change-Id: I738a536289d8d41785b1952e28313dac5f19d45b
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.