1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! tlnat; type level (natural) numbers for rust
//!
//! 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-1024.
//!
//! test/lib.rs: some test code that requires being in a separate
//! file (for whatever reason, may be an ICE in rustc).
//!
//! author: Dalton Woodard
//! contact: daltonmwoodard@gmail.com
//! license: MIT License (c) 2016 by Dalton Woodard
extern crate tlnat;
// testing that these actually work;
// _0 - _10 is reasonable for checking,
// if these work then all the rest should.
// testing that different types
// indeed have different values
// WARNING: This currently does not compile, I think
// due to some internal evaluation order in rustc.
//
// test that this works with constant
// sized arrays;
/*
#[test]
fn test_constant_size_array () -> ()
{
struct zero_arr { vals: [u8; tlnat::_0::evaluate()] }
struct one_arr { vals: [u8; tlnat::_1::evaluate()] }
struct two_arr { vals: [u8; tlnat::_2::VALUE] }
struct three_arr { vals: [u8; tlnat::_3::VALUE] }
struct four_arr { vals: [u8; tlnat::_4::VALUE] }
struct five_arr { vals: [u8; tlnat::_5::VALUE] }
assert_eq!(0, std::mem::size_of::<zero_arr>());
assert_eq!(1, std::mem::size_of::<one_arr>());
assert_eq!(2, std::mem::size_of::<two_arr>());
assert_eq!(3, std::mem::size_of::<three_arr>());
assert_eq!(4, std::mem::size_of::<four_arr>());
assert_eq!(5, std::mem::size_of::<five_arr>());
}
*/