pub trait Cast<T> {
fn cast(self) -> T;
}
use cast_trait::Cast;
use std::num::Wrapping;
assert_eq!(Cast::<isize>::cast(2_usize) * 2_isize, 4_isize);
assert_eq!(Cast::<f32>::cast(2_u32) * 2_f32, 4_f32);
assert_eq!(Cast::<bool>::cast(1_u32), true);
assert_eq!(Cast::<f32>::cast(false), 0_f32);
assert_eq!(Cast::<usize>::cast(true), 1_usize);
assert_eq!(
Cast::<Wrapping<usize>>::cast(Wrapping(1.0)),
Wrapping(1_usize)
);
Loading content...
Loading content...impl Cast<bool> for f32
[src]
impl Cast<bool> for f64
[src]
impl Cast<bool> for i16
[src]
impl Cast<bool> for i32
[src]
impl Cast<bool> for i64
[src]
impl Cast<bool> for isize
[src]
impl Cast<bool> for u16
[src]
impl Cast<bool> for u32
[src]
impl Cast<bool> for u64
[src]
impl Cast<bool> for usize
[src]
impl Cast<f32> for bool
[src]
impl Cast<f32> for isize
[src]
impl Cast<f32> for usize
[src]
impl Cast<f64> for bool
[src]
impl Cast<f64> for isize
[src]
impl Cast<f64> for usize
[src]
impl Cast<i8> for isize
[src]
impl Cast<i8> for usize
[src]
impl Cast<i16> for bool
[src]
impl Cast<i16> for isize
[src]
impl Cast<i16> for usize
[src]
impl Cast<i32> for bool
[src]
impl Cast<i32> for isize
[src]
impl Cast<i32> for usize
[src]
impl Cast<i64> for bool
[src]
impl Cast<i64> for isize
[src]
impl Cast<i64> for usize
[src]
impl Cast<isize> for bool
[src]
impl Cast<isize> for f32
[src]
impl Cast<isize> for f64
[src]
impl Cast<isize> for i8
[src]
impl Cast<isize> for i16
[src]
impl Cast<isize> for i32
[src]
impl Cast<isize> for i64
[src]
impl Cast<isize> for isize
[src]
impl Cast<isize> for u8
[src]
impl Cast<isize> for u16
[src]
impl Cast<isize> for u32
[src]
impl Cast<isize> for u64
[src]
impl Cast<isize> for usize
[src]
impl Cast<u8> for isize
[src]
impl Cast<u8> for usize
[src]
impl Cast<u16> for bool
[src]
impl Cast<u16> for isize
[src]
impl Cast<u16> for usize
[src]
impl Cast<u32> for bool
[src]
impl Cast<u32> for isize
[src]
impl Cast<u32> for usize
[src]
impl Cast<u64> for bool
[src]
impl Cast<u64> for isize
[src]
impl Cast<u64> for usize
[src]
impl Cast<usize> for bool
[src]
impl Cast<usize> for f32
[src]
impl Cast<usize> for f64
[src]
impl Cast<usize> for i8
[src]
impl Cast<usize> for i16
[src]
impl Cast<usize> for i32
[src]
impl Cast<usize> for i64
[src]
impl Cast<usize> for isize
[src]
impl Cast<usize> for u8
[src]
impl Cast<usize> for u16
[src]
impl Cast<usize> for u32
[src]
impl Cast<usize> for u64
[src]
impl Cast<usize> for usize
[src]
impl<A, B> Cast<[B; 1]> for [A; 1] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 2]> for [A; 2] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 3]> for [A; 3] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 4]> for [A; 4] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 5]> for [A; 5] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 6]> for [A; 6] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 7]> for [A; 7] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 8]> for [A; 8] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 9]> for [A; 9] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 10]> for [A; 10] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 11]> for [A; 11] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 12]> for [A; 12] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 13]> for [A; 13] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 14]> for [A; 14] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 15]> for [A; 15] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 16]> for [A; 16] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 17]> for [A; 17] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 18]> for [A; 18] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 19]> for [A; 19] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 20]> for [A; 20] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 21]> for [A; 21] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 22]> for [A; 22] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 23]> for [A; 23] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 24]> for [A; 24] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 25]> for [A; 25] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 26]> for [A; 26] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 27]> for [A; 27] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 28]> for [A; 28] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 29]> for [A; 29] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 30]> for [A; 30] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 31]> for [A; 31] where
A: Clone + Cast<B>,
[src]
impl<A, B> Cast<[B; 32]> for [A; 32] where
A: Clone + Cast<B>,
[src]
Loading content...