1 | pub trait ToF64 {
|
2 | fn to_f64(&self) -> f64;
|
3 | }
|
4 |
|
5 | macro_rules! impl_to_f64 {
|
6 | (for $($t:ty)*) => ($(
|
7 | impl ToF64 for $t {
|
8 | fn to_f64(&self) -> f64 {
|
9 | *self as f64
|
10 | }
|
11 | }
|
12 | )*)
|
13 | }
|
14 |
|
15 | impl_to_f64!(for usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64);
|
16 |
|
17 | pub trait Unsigned {}
|
18 |
|
19 | macro_rules! impl_unsigned {
|
20 | (for $($t:ty)*) => ($(
|
21 | impl Unsigned for $t {}
|
22 | )*)
|
23 | }
|
24 |
|
25 | impl_unsigned!(for usize u8 u16 u32 u64);
|
26 |
|
27 | pub trait Signed {}
|
28 |
|
29 | macro_rules! impl_unsigned {
|
30 | (for $($t:ty)*) => ($(
|
31 | impl Signed for $t {}
|
32 | )*)
|
33 | }
|
34 |
|
35 | impl_unsigned!(for isize i8 i16 i32 i64);
|
36 | |