commit | 4ba8a24259f202f2857325019188d41b0cdaaea6 | [log] [tgz] |
---|---|---|
author | Joel Galenson <jgalenson@google.com> | Wed Aug 05 11:50:19 2020 -0700 |
committer | Joel Galenson <jgalenson@google.com> | Wed Aug 05 11:50:59 2020 -0700 |
tree | 404786a3ad03a6c5ea8afdcae500289bdc791f15 | |
parent | 75ab7e10d2ade06072e920d5824c012961565611 [diff] |
Add metadata files Test: None Change-Id: I7ce55d2528a51a7eaf27f701e66787044df8226c
Procedural macros to derive numeric traits in Rust.
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, }
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.Release notes are available in RELEASES.md.
The num-derive
crate is tested for rustc 1.31 and greater.