commit | 578c2b6ca37e22662c5356d937dfc72b4e7fd397 | [log] [tgz] |
---|---|---|
author | Matthew Maurer <mmaurer@google.com> | Tue Mar 07 17:24:20 2023 -0800 |
committer | Matthew Maurer <mmaurer@google.com> | Tue Mar 07 17:24:20 2023 -0800 |
tree | 4d02240b6a356275f2e27bd9fea034214dd6efe0 | |
parent | e39b6d2dd3c0c7d7fb20f9973e455b769316f49f [diff] |
Make num-derive available to product and vendor Bug: 270690570 Test: mma in external/rust/crates Change-Id: I0f2e1c23c61208d83d75ca0bd0ebc9121635b48b
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.