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