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
pub mod integer16;
pub use self::integer16::Integer16;
pub trait Integer<R = Self> {
fn new() -> Self;
fn set<T: Into<R>>(&mut self, num: T);
fn min_value() -> Self;
fn max_value() -> Self;
}
macro_rules! integer_impl {
($($t:ident)*) => ($(
impl Integer for $t {
fn new() -> Self {
$t::Null
}
fn set<T: Into<$t>>(&mut self, num: T) {
*self = num.into();
}
fn min_value() -> Self {
$t::Num(0)
}
fn max_value() -> Self {
let foo = -1;
foo.into()
}
}
)*)
}
integer_impl!{Integer16}