commit | 7c087e53655799f010f67023f96094253d50269f | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Sat Feb 20 09:49:59 2021 +0000 |
committer | Automerger Merge Worker <[email protected]> | Sat Feb 20 09:49:59 2021 +0000 |
tree | c9a58f4fc6663d85c63dcb9f4a8cf00c85f3993e | |
parent | b65183e8a3caa9abfe00c44cceb5768c6d3c2fd4 [diff] | |
parent | eff95f7605d02c775ff2740bb6cb667dc348b7f4 [diff] |
[automerger skipped] Mark ab/7061308 as merged in stage. am: 9e19b88e6d -s ours am: eff95f7605 -s ours am skip reason: Change-Id I6e519253d66c7fb5673c994d1ea3495c206f7242 with SHA-1 35a1c65702 is in history Original change: undetermined MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I50416bd8e15968a5c16f8b1ec89e2359b069807f
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.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.