commit | 1b3a5204cc5f10c7156fd8fbcd8957ecbd206255 | [log] [tgz] |
---|---|---|
author | android-build-team Robot <[email protected]> | Sun Feb 21 00:05:45 2021 +0000 |
committer | android-build-team Robot <[email protected]> | Sun Feb 21 00:05:45 2021 +0000 |
tree | c9a58f4fc6663d85c63dcb9f4a8cf00c85f3993e | |
parent | 6a2866d005b0794210b4725b83d6700caa29c711 [diff] | |
parent | 7c087e53655799f010f67023f96094253d50269f [diff] |
Snap for 7160059 from 7c087e53655799f010f67023f96094253d50269f to sc-v2-release Change-Id: I26a7286e02d8b6700f450c5daa80b5637e1d8307
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.