no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / third_party / rust / num-derive / README.md
blob20d66a63349a2c610293facc75e44cd5593b96f8
1 # num-derive
3 [![crate](https://img.shields.io/crates/v/num-derive.svg)](https://crates.io/crates/num-derive)
4 [![documentation](https://docs.rs/num-derive/badge.svg)](https://docs.rs/num-derive)
5 [![minimum rustc 1.56](https://img.shields.io/badge/rustc-1.56+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
6 [![build status](https://github.com/rust-num/num-derive/workflows/master/badge.svg)](https://github.com/rust-num/num-derive/actions)
8 Procedural macros to derive numeric traits in Rust.
10 ## Usage
12 Add this to your `Cargo.toml`:
14 ```toml
15 [dependencies]
16 num-traits = "0.2"
17 num-derive = "0.4"
18 ```
20 and this to your crate root:
22 ```rust
23 #[macro_use]
24 extern crate num_derive;
25 ```
27 Then you can derive traits on your own types:
29 ```rust
30 #[derive(FromPrimitive, ToPrimitive)]
31 enum Color {
32     Red,
33     Blue,
34     Green,
36 ```
38 ## Optional features
40 - **`full-syntax`** — Enables `num-derive` to handle enum discriminants
41   represented by complex expressions. Usually can be avoided by
42   [utilizing constants], so only use this feature if namespace pollution is
43   undesired and [compile time doubling] is acceptable.
45 [utilizing constants]: https://github.com/rust-num/num-derive/pull/3#issuecomment-359044704
46 [compile time doubling]: https://github.com/rust-num/num-derive/pull/3#issuecomment-359172588
48 ## Releases
50 Release notes are available in [RELEASES.md](RELEASES.md).
52 ## Compatibility
54 The `num-derive` crate is tested for rustc 1.56 and greater.
56 ## License
58 Licensed under either of
60  * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
61  * [MIT license](http://opensource.org/licenses/MIT)
63 at your option.
65 ### Contribution
67 Unless you explicitly state otherwise, any contribution intentionally submitted
68 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
69 dual licensed as above, without any additional terms or conditions.