3 releases
Uses old Rust 2015
0.1.2 | Jan 7, 2016 |
---|---|
0.1.1 | Jan 6, 2016 |
0.1.0 | Jan 6, 2016 |
#5 in #non-negative
88KB
2K
SLoC
tlnat
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
Build info
tlnat requires usage of feature(associated_consts)
and
feature(const_fn)
.
Example usage
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
pub const fn evaluate () -> T;
which always returns VALUE
.
There are traits IntegralConstant
UnsignedIntegralConstant
, the latter of
which all default types _n
implement.
To define new such types the macros integral_constant!
and
unsigned_integral_constant!
are provided, which take
($name : ident, $val : expr)
as arguments; the types provided by default were
created, for example, by invocation of unsigned_integral_constant!(_0, 0);
.
Known issues:
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
Misc.
If your project uses tlnat please feel free to make a pull request to add to the following list.
Projects using tlnat: