hexga_math/number/
cast_to_primitive.rs1use crate::*;
2
3pub trait ToFloat
28{
29 type Output;
30 fn to_float(self) -> Self::Output;
31}
32impl<T> ToFloat for T where T: CastIntoComposite<float>
33{
34 type Output=T::Output;
35 fn to_float(self) -> Self::Output { self.cast_into_composite() }
36}
37
38pub trait ToF32
39{
40 type Output;
41 fn to_f32(self) -> Self::Output;
42}
43impl<T> ToF32 for T where T: CastIntoComposite<f32>
44{
45 type Output=T::Output;
46 fn to_f32(self) -> Self::Output { self.cast_into_composite() }
47}
48
49pub trait ToF64
50{
51 type Output;
52 fn to_f64(self) -> Self::Output;
53}
54impl<T> ToF64 for T where T: CastIntoComposite<f64>
55{
56 type Output=T::Output;
57 fn to_f64(self) -> Self::Output { self.cast_into_composite() }
58}
59
60
61pub trait ToInt
63{
64 type Output;
65 fn to_int(self) -> Self::Output;
66}
67impl<T> ToInt for T where T: CastIntoComposite<int>
68{
69 type Output=T::Output;
70 fn to_int(self) -> Self::Output { self.cast_into_composite() }
71}
72
73pub trait ToI8
74{
75 type Output;
76 fn to_i8(self) -> Self::Output;
77}
78impl<T> ToI8 for T where T: CastIntoComposite<i8>
79{
80 type Output=T::Output;
81 fn to_i8(self) -> Self::Output { self.cast_into_composite() }
82}
83
84pub trait ToI16
85{
86 type Output;
87 fn to_i16(self) -> Self::Output;
88}
89impl<T> ToI16 for T where T: CastIntoComposite<i16>
90{
91 type Output=T::Output;
92 fn to_i16(self) -> Self::Output { self.cast_into_composite() }
93}
94
95pub trait ToI32
96{
97 type Output;
98 fn to_i32(self) -> Self::Output;
99}
100impl<T> ToI32 for T where T: CastIntoComposite<i32>
101{
102 type Output=T::Output;
103 fn to_i32(self) -> Self::Output { self.cast_into_composite() }
104}
105
106pub trait ToI64
107{
108 type Output;
109 fn to_i64(self) -> Self::Output;
110}
111impl<T> ToI64 for T where T: CastIntoComposite<i64>
112{
113 type Output=T::Output;
114 fn to_i64(self) -> Self::Output { self.cast_into_composite() }
115}
116
117pub trait ToISize
118{
119 type Output;
120 fn to_isize(self) -> Self::Output;
121}
122impl<T> ToISize for T where T: CastIntoComposite<isize>
123{
124 type Output=T::Output;
125 fn to_isize(self) -> Self::Output { self.cast_into_composite() }
126}
127
128pub trait ToUInt
130{
131 type Output;
132 fn to_uint(self) -> Self::Output;
133}
134impl<T> ToUInt for T where T: CastIntoComposite<uint>
135{
136 type Output=T::Output;
137 fn to_uint(self) -> Self::Output { self.cast_into_composite() }
138}
139
140pub trait ToU8
141{
142 type Output;
143 fn to_u8(self) -> Self::Output;
144}
145impl<T> ToU8 for T where T: CastIntoComposite<u8>
146{
147 type Output=T::Output;
148 fn to_u8(self) -> Self::Output { self.cast_into_composite() }
149}
150
151pub trait ToU16
152{
153 type Output;
154 fn to_u16(self) -> Self::Output;
155}
156impl<T> ToU16 for T where T: CastIntoComposite<u16>
157{
158 type Output=T::Output;
159 fn to_u16(self) -> Self::Output { self.cast_into_composite() }
160}
161
162pub trait ToU32
163{
164 type Output;
165 fn to_u32(self) -> Self::Output;
166}
167impl<T> ToU32 for T where T: CastIntoComposite<u32>
168{
169 type Output=T::Output;
170 fn to_u32(self) -> Self::Output { self.cast_into_composite() }
171}
172
173pub trait ToU64
174{
175 type Output;
176 fn to_u64(self) -> Self::Output;
177}
178impl<T> ToU64 for T where T: CastIntoComposite<u64>
179{
180 type Output=T::Output;
181 fn to_u64(self) -> Self::Output { self.cast_into_composite() }
182}
183
184pub trait ToUSize
185{
186 type Output;
187 fn to_usize(self) -> Self::Output;
188}
189impl<T> ToUSize for T where T: CastIntoComposite<usize>
190{
191 type Output=T::Output;
192 fn to_usize(self) -> Self::Output { self.cast_into_composite() }
193}