#mathematics #numerics

macro num-derive

Numeric syntax extensions

13 releases

0.2.3 Oct 3, 2018
0.2.2 May 22, 2018
0.2.0 Feb 21, 2018
0.1.41 Jul 15, 2017
0.1.38 Nov 28, 2016

#4 in Math

Download history 10838/week @ 2018-10-21 12685/week @ 2018-10-28 12678/week @ 2018-11-04 12670/week @ 2018-11-11 14119/week @ 2018-11-18 12337/week @ 2018-11-25 12852/week @ 2018-12-02 14062/week @ 2018-12-09 15406/week @ 2018-12-16 15947/week @ 2018-12-23 11498/week @ 2018-12-30 12971/week @ 2019-01-06 11580/week @ 2019-01-13

56,449 downloads per month
Used in 240 crates (20 directly)

MIT/Apache

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

~1MB
~21K SLoC

  • build build.rs
  • dev num 0.2