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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use num_traits;
pub trait Zero {
fn zero() -> Self;
}
impl<T: num_traits::Zero> Zero for T {
fn zero() -> T { num_traits::Zero::zero() }
}
pub trait One {
fn one() -> Self;
}
impl<T: num_traits::One> One for T {
fn one() -> T { num_traits::One::one() }
}
pub trait Round : Copy { fn round(self) -> Self; }
pub trait Floor : Copy { fn floor(self) -> Self; }
pub trait Ceil : Copy { fn ceil(self) -> Self; }
impl Round for f32 { fn round(self) -> Self { self.round() } }
impl Round for f64 { fn round(self) -> Self { self.round() } }
impl Round for i16 { fn round(self) -> Self { self } }
impl Round for u16 { fn round(self) -> Self { self } }
impl Round for i32 { fn round(self) -> Self { self } }
impl Round for i64 { fn round(self) -> Self { self } }
impl Round for u32 { fn round(self) -> Self { self } }
impl Round for u64 { fn round(self) -> Self { self } }
impl Round for usize { fn round(self) -> Self { self } }
impl Round for isize { fn round(self) -> Self { self } }
impl Floor for f32 { fn floor(self) -> Self { self.floor() } }
impl Floor for f64 { fn floor(self) -> Self { self.floor() } }
impl Floor for i16 { fn floor(self) -> Self { self } }
impl Floor for u16 { fn floor(self) -> Self { self } }
impl Floor for i32 { fn floor(self) -> Self { self } }
impl Floor for i64 { fn floor(self) -> Self { self } }
impl Floor for u32 { fn floor(self) -> Self { self } }
impl Floor for u64 { fn floor(self) -> Self { self } }
impl Floor for usize { fn floor(self) -> Self { self } }
impl Floor for isize { fn floor(self) -> Self { self } }
impl Ceil for f32 { fn ceil(self) -> Self { self.ceil() } }
impl Ceil for f64 { fn ceil(self) -> Self { self.ceil() } }
impl Ceil for i16 { fn ceil(self) -> Self { self } }
impl Ceil for u16 { fn ceil(self) -> Self { self } }
impl Ceil for i32 { fn ceil(self) -> Self { self } }
impl Ceil for i64 { fn ceil(self) -> Self { self } }
impl Ceil for u32 { fn ceil(self) -> Self { self } }
impl Ceil for u64 { fn ceil(self) -> Self { self } }
impl Ceil for usize { fn ceil(self) -> Self { self } }
impl Ceil for isize { fn ceil(self) -> Self { self } }