commit | 4bd607925d2165198d2e408dcc27bec95622ac42 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Fri Oct 09 02:27:08 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Oct 09 02:27:08 2020 +0000 |
tree | fe685f62dad88790e374a48934534d4517add021 | |
parent | 0c157635042337b57907d84f25fbf39c62a4a6fe [diff] | |
parent | b0b4bd6cd57da917b04fb59b6a3a78789a46d0c1 [diff] |
[automerger skipped] Skip ab/6749736 in stage. am: b0b4bd6cd5 -s ours am skip reason: Change-Id Ia432a357d0203a811c705fed9b67b7e40e742fd7 with SHA-1 4cc632ddea is in history Original change: https://googleplex-android-review.googlesource.com/c/platform/external/rust/crates/num-derive/+/12797301 Change-Id: If4245b34b5162b3bdbfd81d96b32c590c26dcb93
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.