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
pub trait ToF64 {
    fn to_f64(&self) -> f64;
}

macro_rules! impl_to_f64 {
  (for $($t:ty)*) => ($(
      impl ToF64 for $t {
          fn to_f64(&self) -> f64 {
              *self as f64
          }
      }
  )*)
}

impl_to_f64!(for usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64);

pub trait Unsigned {}

macro_rules! impl_unsigned {
  (for $($t:ty)*) => ($(
      impl Unsigned for $t {}
  )*)
}

impl_unsigned!(for usize u8 u16 u32 u64);

pub trait Signed {}

macro_rules! impl_unsigned {
  (for $($t:ty)*) => ($(
      impl Signed for $t {}
  )*)
}

impl_unsigned!(for isize i8 i16 i32 i64);