commit | a6d38d96dc2085667e926cd3a4a3e9e1735c5225 | [log] [tgz] |
---|---|---|
author | Chih-Hung Hsieh <chh@google.com> | Thu Sep 17 20:00:51 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Sep 17 20:00:51 2020 +0000 |
tree | 61f8cf9de82b1871077110126fbb23316afbde28 | |
parent | c950f31124b5ce5a76bba2f5c421bf93ccd6c190 [diff] | |
parent | cbb466efc6aba87ff4fde376c5fcfe04468ee201 [diff] |
Add num-derive/OWNERS am: 84f183eccb am: 13f27a6182 am: ccde88a1b7 am: 56042adecd am: d241a0eae1 am: cbb466efc6 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/num-derive/+/1428986 Change-Id: Ieb0427af26ac79dc024c1b821a7e618a6ab8efb1
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.