commit | 98f11b30791e1961d842eb2a6a1fd88521e4579f | [log] [tgz] |
---|---|---|
author | Scott Lobdell <slobdell@google.com> | Thu Oct 15 11:45:39 2020 -0700 |
committer | Scott Lobdell <slobdell@google.com> | Thu Oct 15 11:45:39 2020 -0700 |
tree | fe685f62dad88790e374a48934534d4517add021 | |
parent | 297d66ebb89ccf6269ba5d70eb2fd18790f50f1b [diff] | |
parent | 63e3350576163857d64193532b4f04743db8237d [diff] |
Merge SP1A.201015.001 Change-Id: I2fd669145c74937506c697df889ac6087996dc4f
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.