commit | 5426ca01c6f5c71879247dcfc5256a6f46185e00 | [log] [tgz] |
---|---|---|
author | Xin Li <[email protected]> | Sat Feb 20 11:40:44 2021 +0000 |
committer | Automerger Merge Worker <[email protected]> | Sat Feb 20 11:40:44 2021 +0000 |
tree | c9a58f4fc6663d85c63dcb9f4a8cf00c85f3993e | |
parent | 8a4aa9484045af9bfe4d5956195f4d01eadacade [diff] | |
parent | 7c087e53655799f010f67023f96094253d50269f [diff] |
[automerger skipped] Mark ab/7061308 as merged in stage. am: 9e19b88e6d -s ours am: eff95f7605 -s ours am: 7c087e5365 -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: I68a82b3b691d31248e51f4ea0e3ed2e3e8b229b6
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.