Skip to content
Procedural macros to derive numeric traits in Rust
Branch: master
Clone or download
bors and cuviper Merge #26
26: Use autocfg to probe for i128 r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
Latest commit bbaeeb1 May 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
check Allow deriving for no-std targets Jan 25, 2019
ci Mask lints the same way as serde Apr 23, 2019
src Fix clippy warnings Apr 23, 2019
tests Fix clippy warnings Apr 23, 2019
.gitignore Update num-macros to Rust master May 14, 2015
.travis.yml Check formatting in CI Apr 16, 2019
Cargo.toml Use autocfg to probe for i128 May 10, 2019
LICENSE-APACHE Initial seeding from rust repo Sep 16, 2014
LICENSE-MIT Initial seeding from rust repo Sep 16, 2014
README.md Add a tiny bit of documentation Feb 21, 2018
RELEASES.md Release 0.2.5 Apr 23, 2019
bors.toml Enable bors-ng Jul 9, 2017
build.rs

README.md

num-derive

crate documentation Travis status

Procedural macros to derive numeric traits in Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
num-traits = "0.2"
num-derive = "0.2"

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.15 and greater.

You can’t perform that action at this time.