[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
tree: fe685f62dad88790e374a48934534d4517add021
  1. src/
  2. tests/
  3. .cargo_vcs_info.json
  4. .gitignore
  5. Android.bp
  6. Cargo.toml
  7. Cargo.toml.orig
  8. LICENSE-APACHE
  9. LICENSE-MIT
  10. METADATA
  11. MODULE_LICENSE_APACHE2
  12. OWNERS
  13. README.md
  14. RELEASES.md
README.md

num-derive

crate documentation minimum rustc 1.31 build status

Procedural macros to derive numeric traits in Rust.

Usage

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,
}

Optional features

  • 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.

Releases

Release notes are available in RELEASES.md.

Compatibility

The num-derive crate is tested for rustc 1.31 and greater.