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
extern crate num_traits;

use num_traits::cast::AsPrimitive;

pub trait UInt where
    Self: AsPrimitive<u8> +
        Eq +
        std::ops::SubAssign<Self> +
        std::ops::AddAssign +
        std::ops::Shl<u8, Output = Self> +
        std::ops::ShrAssign<u8>
{
    const _0: Self;
    const _1: Self;
    fn from_u8(v: u8) -> Self;
}

impl UInt for u8 {
    const _0: u8 = 0;
    const _1: u8 = 1;
    fn from_u8(v: u8) -> Self { v }
}
impl UInt for u16 {
    const _0: u16 = 0;
    const _1: u16 = 1;
    fn from_u8(v: u8) -> Self { v as Self }
}
impl UInt for u32 {
    const _0: u32 = 0;
    const _1: u32 = 1;
    fn from_u8(v: u8) -> Self { v as Self }
}
impl UInt for u64 {
    const _0: u64 = 0;
    const _1: u64 = 1;
    fn from_u8(v: u8) -> Self { v as Self }
}
impl UInt for u128 {
    const _0: u128 = 0;
    const _1: u128 = 1;
    fn from_u8(v: u8) -> Self { v as Self }
}