mutils/num/
half.rs

1pub trait Half {
2    fn half(&self) -> Self;
3}
4
5impl Half for usize {
6    fn half(&self) -> Self {
7        self / 2
8    }
9}
10
11impl Half for isize {
12    fn half(&self) -> Self {
13        self / 2
14    }
15}
16
17impl Half for u8 {
18    fn half(&self) -> Self {
19        self / 2
20    }
21}
22
23impl Half for u16 {
24    fn half(&self) -> Self {
25        self / 2
26    }
27}
28
29impl Half for u32 {
30    fn half(&self) -> Self {
31        self / 2
32    }
33}
34
35impl Half for u64 {
36    fn half(&self) -> Self {
37        self / 2
38    }
39}
40
41impl Half for u128 {
42    fn half(&self) -> Self {
43        self / 2
44    }
45}
46
47impl Half for i8 {
48    fn half(&self) -> Self {
49        self / 2
50    }
51}
52
53impl Half for i16 {
54    fn half(&self) -> Self {
55        self / 2
56    }
57}
58
59impl Half for i32 {
60    fn half(&self) -> Self {
61        self / 2
62    }
63}
64
65impl Half for i64 {
66    fn half(&self) -> Self {
67        self / 2
68    }
69}
70
71impl Half for i128 {
72    fn half(&self) -> Self {
73        self / 2
74    }
75}
76
77impl Half for f32 {
78    fn half(&self) -> Self {
79        self / 2.0
80    }
81}
82
83impl Half for f64 {
84    fn half(&self) -> Self {
85        self / 2.0
86    }
87}