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
newtype! {
#[doc = r"A 7-bit integer (0 - 127)."]
name = U7, repr = u8, max = 127
}
impl_from_newtype_to_newtype!(crate::U4, U7);
impl_from_newtype_to_primitive!(U7, u8);
impl_from_newtype_to_primitive!(U7, i8);
impl_from_newtype_to_primitive!(U7, u16);
impl_from_newtype_to_primitive!(U7, i16);
impl_from_newtype_to_primitive!(U7, u32);
impl_from_newtype_to_primitive!(U7, i32);
impl_from_newtype_to_primitive!(U7, u64);
impl_from_newtype_to_primitive!(U7, i64);
impl_from_newtype_to_primitive!(U7, u128);
impl_from_newtype_to_primitive!(U7, i128);
impl_from_newtype_to_primitive!(U7, usize);
impl_from_newtype_to_primitive!(U7, isize);
impl_try_from_newtype_to_newtype!(crate::U14, U7);
impl_try_from_primitive_to_newtype!(u8, U7);
impl_try_from_primitive_to_newtype!(u16, U7);
impl_try_from_primitive_to_newtype!(i16, U7);
impl_try_from_primitive_to_newtype!(u32, U7);
impl_try_from_primitive_to_newtype!(i32, U7);
impl_try_from_primitive_to_newtype!(u64, U7);
impl_try_from_primitive_to_newtype!(i64, U7);
impl_try_from_primitive_to_newtype!(u128, U7);
impl_try_from_primitive_to_newtype!(i128, U7);
impl_try_from_primitive_to_newtype!(usize, U7);
impl_try_from_primitive_to_newtype!(isize, U7);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_successful() {
U7::new(127);
}
#[test]
#[should_panic(expected = "128 is not a valid U7 value")]
fn new_failing() {
U7::new(128);
}
}