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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#![forbid(unsafe_code)]
#![no_std]
#![warn(missing_docs)]
#![deny(missing_docs)]
extern crate tuple_macro;
use tuple_macro::tuple_length;
pub trait TupLen {
fn len(&self) -> usize;
}
impl TupLen for () {
#[inline]
fn len(&self) -> usize {
0usize
}
}
tuple_length!();
#[cfg(test)]
mod tuple_len_tests {
use super::*;
#[cfg(all(not(feature = "16"), not(feature = "32"), not(feature = "64")))]
#[test]
fn features_8_ok() {
assert_eq!((1i8, 2u8, 3i16, 4u16, 5i32, 6u32, 7i64, 8u64).len(), 8usize);
}
#[cfg(all(not(feature = "32"), not(feature = "64"), feature = "16"))]
#[test]
fn features_16_ok() {
assert_eq!(
(
1i8, 2u8, 3i16, 4u16, 5i32, 6u32, 7i64, 8u64, 9isize, 10usize, 11i128, 12u128,
13i8, 14u8, 15i16, 16u16
)
.len(),
16usize
);
}
#[cfg(all(not(feature = "16"), not(feature = "64"), feature = "32"))]
#[test]
fn features_32_ok() {
assert_eq!(
(
1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8, 13u8, 14u8, 15u8,
16u8, 17u8, 18u8, 19u8, 20u8, 21u8, 22u8, 23u8, 24u8, 25u8, 26u8, 27u8, 28u8, 29u8,
30u8, 31u8, 32u8
)
.len(),
32usize
);
}
#[cfg(all(not(feature = "16"), not(feature = "32"), feature = "64"))]
#[test]
fn features_64_ok() {
assert_eq!(
(
1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8, 13u8, 14u8, 15u8,
16u8, 17u8, 18u8, 19u8, 20u8, 21u8, 22u8, 23u8, 24u8, 25u8, 26u8, 27u8, 28u8, 29u8,
30u8, 31u8, 32u8, 33u8, 34u8, 35u8, 36u8, 37u8, 38u8, 39u8, 40u8, 41u8, 42u8, 43u8,
44u8, 45u8, 46u8, 47u8, 48u8, 49u8, 50u8, 51u8, 52u8, 53u8, 54u8, 55u8, 56u8, 57u8,
58u8, 59u8, 60u8, 61u8, 62u8, 63u8, 64u8
)
.len(),
64usize
);
}
}