#mathematics #numerics

macro num-derive

Numeric syntax extensions

15 releases

0.2.5 Apr 23, 2019
0.2.4 Jan 26, 2019
0.2.3 Oct 3, 2018
0.2.2 May 22, 2018
0.1.38 Nov 28, 2016

#13 in Math

Download history 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 16765/week @ 2019-02-27 17895/week @ 2019-03-06 16379/week @ 2019-03-13 15047/week @ 2019-03-20 15470/week @ 2019-03-27 17412/week @ 2019-04-03 16742/week @ 2019-04-10 15269/week @ 2019-04-17

69,872 downloads per month
Used in 341 crates (38 directly)

MIT/Apache

33KB
611 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

~777KB
~17K SLoC