Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
patches/ | 25-Apr-2025 | - | 120 | 113 | ||
src/ | 25-Apr-2025 | - | 955 | 693 | ||
tests/ | 25-Apr-2025 | - | 324 | 233 | ||
.cargo-checksum.json | D | 25-Apr-2025 | 1.4 KiB | 1 | 1 | |
Android.bp | D | 25-Apr-2025 | 935 | 37 | 32 | |
Cargo.toml | D | 25-Apr-2025 | 1.3 KiB | 56 | 47 | |
LICENSE | D | 25-Apr-2025 | 10.6 KiB | 202 | 169 | |
LICENSE-APACHE | D | 25-Apr-2025 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | D | 25-Apr-2025 | 1 KiB | 26 | 22 | |
METADATA | D | 25-Apr-2025 | 374 | 18 | 17 | |
MODULE_LICENSE_APACHE2 | D | 25-Apr-2025 | 0 | |||
README.md | D | 25-Apr-2025 | 1.9 KiB | 70 | 47 | |
RELEASES.md | D | 25-Apr-2025 | 3.1 KiB | 106 | 59 | |
TEST_MAPPING | D | 25-Apr-2025 | 521 | 24 | 23 | |
cargo_embargo.json | D | 25-Apr-2025 | 71 | 6 | 5 | |
rules.mk | D | 25-Apr-2025 | 544 | 18 | 11 |
README.md
1# num-derive 2 3[](https://crates.io/crates/num-derive) 4[](https://docs.rs/num-derive) 5[](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) 6[](https://github.com/rust-num/num-derive/actions) 7 8Procedural macros to derive numeric traits in Rust. 9 10## Usage 11 12Add this to your `Cargo.toml`: 13 14```toml 15[dependencies] 16num-traits = "0.2" 17num-derive = "0.3" 18``` 19 20and this to your crate root: 21 22```rust 23#[macro_use] 24extern crate num_derive; 25``` 26 27Then you can derive traits on your own types: 28 29```rust 30#[derive(FromPrimitive, ToPrimitive)] 31enum Color { 32 Red, 33 Blue, 34 Green, 35} 36``` 37 38## Optional features 39 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. 44 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 47 48## Releases 49 50Release notes are available in [RELEASES.md](RELEASES.md). 51 52## Compatibility 53 54The `num-derive` crate is tested for rustc 1.31 and greater. 55 56## License 57 58Licensed under either of 59 60 * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) 61 * [MIT license](http://opensource.org/licenses/MIT) 62 63at your option. 64 65### Contribution 66 67Unless you explicitly state otherwise, any contribution intentionally submitted 68for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 69dual licensed as above, without any additional terms or conditions. 70