commit | 6722c3284f3d95243409e10eb344dff284c6b30c | [log] [tgz] |
---|---|---|
author | Chih-Hung Hsieh <chh@google.com> | Tue Aug 25 20:49:21 2020 -0700 |
committer | Chih-Hung Hsieh <chh@google.com> | Tue Aug 25 20:49:21 2020 -0700 |
tree | 926f4fbc1b07deead6970f1e7d8676da481a3436 | |
parent | f22aa339eae592584748c84f2892ced2f5040cdd [diff] |
Fix num-derive/METADATA Bug: 166324735 Test: make Change-Id: I793af3d8183e9224e127259cc5c62d5a5d9938c5
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.