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
tree: 61f8cf9de82b1871077110126fbb23316afbde28
  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.