Type-level natural numbers in Rust
This library implements type-level natural numbers using traits and associated types. At this stage it is meant to serve as a demonstration more than anything else.
rust
fn example() {
let _: Answer< S<S<S<S<S<Z>>>>> > = Add::< S<S<S<Z>>> , S<S<Z>> >::query();
let _: Answer< N06 > = Mul::< N03 , N02 >::query();
let _: Answer< N08 > = Exp::< N03 , N02 >::query();
let _: Answer< N24 > = Fac::< N04 >::query();
}
See the API documentation here.
You can install both with the following:
$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh
See Installing Rust for further details.
$ cargo build ## build library and binary
$ cargo test ## run tests in ./tests
$ cargo bench ## run benchmarks in ./benches
There is an IRC channel on freenode (chat.freenode.net) at #epsilonz.