1use super::*;
2
3impl ToU8 for i64 {
4 fn to_u8(self) -> u8 {
5 self.to_u64().to_u8()
6 }
7}
8impl ToU16 for i64 {
9 fn to_u16(self) -> u16 {
10 self.to_u64().to_u16()
11 }
12}
13impl ToU32 for i64 {
14 fn to_u32(self) -> u32 {
15 self.to_u64().to_u32()
16 }
17}
18impl ToU64 for i64 {
19 fn to_u64(self) -> u64 {
20 if self & Self::MIN != 0 {
21 0
22 } else {
23 self as u64
24 }
25 }
26}
27impl ToU128 for i64 {
28 fn to_u128(self) -> u128 {
29 self.to_u64().as_u128()
30 }
31}
32
33impl ToI8 for i64 {
34 fn to_i8(self) -> i8 {
35 match self {
36 ..-0x80 => i8::MIN,
37 -0x80..0x80 => self as i8,
38 0x80.. => i8::MAX,
39 }
40 }
41}
42impl ToI16 for i64 {
43 fn to_i16(self) -> i16 {
44 match self {
45 ..-0x8000 => i16::MIN,
46 -0x8000..0x8000 => self as i16,
47 0x8000.. => i16::MAX,
48 }
49 }
50}
51impl ToI32 for i64 {
52 fn to_i32(self) -> i32 {
53 match self {
54 ..-0x8000_0000 => i32::MIN,
55 -0x8000_0000..0x8000_0000 => self as i32,
56 0x8000_0000.. => i32::MAX,
57 }
58 }
59}
60impl AsI64 for i64 {
61 fn as_i64(self) -> i64 {
62 self
63 }
64}
65impl AsI128 for i64 {
66 fn as_i128(self) -> i128 {
67 self.into()
68 }
69}
70
71impl ToF32 for i64 {
72 fn to_f32(self) -> f32 {
73 self as f32
74 }
75}
76impl ToF64 for i64 {
77 fn to_f64(self) -> f64 {
78 self as f64
79 }
80}