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
pub trait MinMax {
    fn min() -> Self;
    fn max() -> Self;
}

macro_rules! min_max {
    ($type:ident) => {
        impl MinMax for $type {
            /// Gets a minimal possible value for the type.
            fn min() -> $type {
                $type::MIN
            }

            /// Gets a maximal possible value for the type.
            fn max() -> $type {
                $type::MAX
            }
        }
    };
}

min_max!(i8);
min_max!(u8);
min_max!(i16);
min_max!(u16);
min_max!(i32);
min_max!(u32);
min_max!(i64);
min_max!(u64);
min_max!(isize);
min_max!(usize);