default_constructor/
convert.rs1pub trait InferInto<A, Marker>: Sized {
5 fn into(self) -> A;
6}
7
8impl<T, U> InferInto<U, ()> for T
9where
10 T: Into<U>,
11{
12 fn into(self) -> U {
13 Into::<U>::into(self)
14 }
15}
16
17pub fn infer_into<T, U, M>(item: T) -> U
19where
20 T: InferInto<U, M>,
21{
22 InferInto::into(item)
23}
24
25pub trait StandardConverters<F> {
27 fn into(self) -> F;
28}
29
30impl<T, F> InferInto<F, bool> for T
31where
32 T: StandardConverters<F>,
33{
34 fn into(self) -> F {
35 StandardConverters::<F>::into(self)
36 }
37}
38
39impl StandardConverters<f64> for i64 {
40 fn into(self) -> f64 {
41 self as f64
42 }
43}
44
45macro_rules! std_convert {
46 ($($ty: ty),*) => {
47 $(
48 impl StandardConverters<$ty> for i32 {
49 fn into(self) -> $ty {
50 self as $ty
51 }
52 }
53 )*
54 };
55}
56
57std_convert!(u8, u16, u32, u64, usize, u128, i8, i16, f32);