#mathematics #numerics

macro num-derive

Numeric syntax extensions

14 releases

0.2.4 Jan 26, 2019
0.2.3 Oct 3, 2018
0.2.2 May 22, 2018
0.2.0 Feb 21, 2018
0.1.38 Nov 28, 2016

#4 in Math

Download history 13382/week @ 2018-11-14 12599/week @ 2018-11-21 13066/week @ 2018-11-28 14585/week @ 2018-12-05 15453/week @ 2018-12-12 23694/week @ 2018-12-19 15174/week @ 2018-12-26 13549/week @ 2019-01-02 14263/week @ 2019-01-09 14435/week @ 2019-01-16 15494/week @ 2019-01-23 15761/week @ 2019-01-30 19048/week @ 2019-02-06 16484/week @ 2019-02-13 16209/week @ 2019-02-20

57,852 downloads per month
Used in 293 crates (28 directly)

MIT/Apache

33KB
615 lines

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.

Dependencies

~794KB
~18K SLoC