• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..31-Mar-2022-

build/H31-Mar-2022-1,074902

src/H31-Mar-2022-6,2734,637

tests/H31-Mar-2022-32

.cargo-checksum.jsonH A D03-May-202289 11

CHANGELOG.mdH A D31-Mar-20223.9 KiB10079

Cargo.tomlH A D31-Mar-20221.2 KiB3430

LICENSEH A D31-Mar-202217 11

LICENSE-APACHEH A D31-Mar-202210.6 KiB201169

LICENSE-MITH A D31-Mar-20221.1 KiB2217

README.mdH A D31-Mar-20222.2 KiB6845

clippy.tomlH A D31-Mar-202234 21

rustfmt.tomlH A D31-Mar-202235 21

README.md

1[![crates.io](https://img.shields.io/crates/v/typenum.svg)](https://crates.io/crates/typenum)
2[![Build Status](https://github.com/paholg/typenum/actions/workflows/check.yml/badge.svg)](https://github.com/paholg/typenum/actions/workflows/check.yml)
3
4Typenum
5=====
6
7Typenum is a Rust library for type-level numbers evaluated at compile time. It
8currently supports bits, unsigned integers, and signed integers.
9
10Typenum depends only on libcore, and so is suitable for use on any platform!
11
12For the full documentation, go [here](https://docs.rs/typenum).
13
14### Importing
15
16While `typenum` is divided into several modules, they are all re-exported
17through the crate root, so you can import anything contained herein with `use
18typenum::whatever;`, ignoring the crate structure.
19
20You may also find it useful to treat the `consts` module as a prelude, perfoming
21a glob import.
22
23### Example
24
25Here is a trivial example of `typenum`'s use:
26
27```rust
28use typenum::{Sum, Exp, Integer, N2, P3, P4};
29
30type X = Sum<P3, P4>;
31assert_eq!(<X as Integer>::to_i32(), 7);
32
33type Y = Exp<N2, P3>;
34assert_eq!(<Y as Integer>::to_i32(), -8);
35```
36
37For a non-trivial example of its use, see one of the crates that depends on
38it. The full list is
39[here](https://crates.io/crates/typenum/reverse_dependencies). Of note are
40[dimensioned](https://crates.io/crates/dimensioned/) which does compile-time
41type checking for arbitrary unit systems and
42[generic-array](https://crates.io/crates/generic-array/) which provides arrays
43whose length you can generically refer to.
44
45### Error messages
46
47
48Typenum's error messages aren't great, and can be difficult to parse. The good
49news is that the fine folks at Auxon have written a tool to help with it. Please
50take a look at [tnfilt](https://github.com/auxoncorp/tnfilt).
51
52### License
53
54Licensed under either of
55
56 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
57   http://www.apache.org/licenses/LICENSE-2.0)
58 * MIT license
59   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
60
61at your option.
62
63### Contribution
64
65Unless you explicitly state otherwise, any contribution intentionally submitted
66for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
67dual licensed as above, without any additional terms or conditions.
68