This project is essentially a stop-gap until the rust team implements generics that can be parameterized by values. The infrastructure exists to define other types of objects, but currently the only implemented values are natural numbers 0 through 2048.
author: Dalton Woodard contact: daltonmwoodard@gmail.com license: MIT License (c) 2016 by Dalton Woodard
tlnat requires usage of feature(associated_consts)
and
feature(const_fn)
.
The types each have the format of _n
for some number n >= 0
, along
with the associated constant _n::VALUE
which satisfies _n::VALUE == n
.
Each type provided implements the associated constant VALUE
and the function
rust
const fn evaluate () -> T;
which always returns VALUE
.
To define new such types the macro type_level_constant!
is provided, which
takes ($name : ident, $t : type, $val : expr)
as arguments; the types
provided by default were created, for example, by invocation of
type_level_constant!(_0, u64, 0);
.
Currently using _n::VALUE
, although it is indeed a compile-time constant,
to specify the size of a fixed-size array, such as [u8; _n::VALUE]
does not
compile. I believe it is related to the issue discussed in this issue:
https://github.com/rust-lang/rust/issues/25145
If your project uses tlnat please feel free to make a pull request to add to the following list.
Projects using tlnat: