Lines Matching refs:cast
11 use num_traits::cast::*;
98 assert_eq!(cast::<f64, i32>(source), None); in float_to_integer_checks_overflow()
106 assert_eq!(None, cast::<f64, isize>(big_f)); in cast_to_int_checks_overflow()
107 assert_eq!(None, cast::<f64, i8>(big_f)); in cast_to_int_checks_overflow()
108 assert_eq!(None, cast::<f64, i16>(big_f)); in cast_to_int_checks_overflow()
109 assert_eq!(None, cast::<f64, i32>(big_f)); in cast_to_int_checks_overflow()
110 assert_eq!(None, cast::<f64, i64>(big_f)); in cast_to_int_checks_overflow()
112 assert_eq!(Some(normal_f as isize), cast::<f64, isize>(normal_f)); in cast_to_int_checks_overflow()
113 assert_eq!(Some(normal_f as i8), cast::<f64, i8>(normal_f)); in cast_to_int_checks_overflow()
114 assert_eq!(Some(normal_f as i16), cast::<f64, i16>(normal_f)); in cast_to_int_checks_overflow()
115 assert_eq!(Some(normal_f as i32), cast::<f64, i32>(normal_f)); in cast_to_int_checks_overflow()
116 assert_eq!(Some(normal_f as i64), cast::<f64, i64>(normal_f)); in cast_to_int_checks_overflow()
118 assert_eq!(None, cast::<f64, isize>(small_f)); in cast_to_int_checks_overflow()
119 assert_eq!(None, cast::<f64, i8>(small_f)); in cast_to_int_checks_overflow()
120 assert_eq!(None, cast::<f64, i16>(small_f)); in cast_to_int_checks_overflow()
121 assert_eq!(None, cast::<f64, i32>(small_f)); in cast_to_int_checks_overflow()
122 assert_eq!(None, cast::<f64, i64>(small_f)); in cast_to_int_checks_overflow()
130 assert_eq!(None, cast::<f64, usize>(big_f)); in cast_to_unsigned_int_checks_overflow()
131 assert_eq!(None, cast::<f64, u8>(big_f)); in cast_to_unsigned_int_checks_overflow()
132 assert_eq!(None, cast::<f64, u16>(big_f)); in cast_to_unsigned_int_checks_overflow()
133 assert_eq!(None, cast::<f64, u32>(big_f)); in cast_to_unsigned_int_checks_overflow()
134 assert_eq!(None, cast::<f64, u64>(big_f)); in cast_to_unsigned_int_checks_overflow()
136 assert_eq!(Some(normal_f as usize), cast::<f64, usize>(normal_f)); in cast_to_unsigned_int_checks_overflow()
137 assert_eq!(Some(normal_f as u8), cast::<f64, u8>(normal_f)); in cast_to_unsigned_int_checks_overflow()
138 assert_eq!(Some(normal_f as u16), cast::<f64, u16>(normal_f)); in cast_to_unsigned_int_checks_overflow()
139 assert_eq!(Some(normal_f as u32), cast::<f64, u32>(normal_f)); in cast_to_unsigned_int_checks_overflow()
140 assert_eq!(Some(normal_f as u64), cast::<f64, u64>(normal_f)); in cast_to_unsigned_int_checks_overflow()
142 assert_eq!(None, cast::<f64, usize>(small_f)); in cast_to_unsigned_int_checks_overflow()
143 assert_eq!(None, cast::<f64, u8>(small_f)); in cast_to_unsigned_int_checks_overflow()
144 assert_eq!(None, cast::<f64, u16>(small_f)); in cast_to_unsigned_int_checks_overflow()
145 assert_eq!(None, cast::<f64, u32>(small_f)); in cast_to_unsigned_int_checks_overflow()
146 assert_eq!(None, cast::<f64, u64>(small_f)); in cast_to_unsigned_int_checks_overflow()
155 assert_eq!(None, cast::<f64, i128>(big_f)); in cast_to_i128_checks_overflow()
156 assert_eq!(None, cast::<f64, u128>(big_f)); in cast_to_i128_checks_overflow()
158 assert_eq!(Some(normal_f as i128), cast::<f64, i128>(normal_f)); in cast_to_i128_checks_overflow()
159 assert_eq!(Some(normal_f as u128), cast::<f64, u128>(normal_f)); in cast_to_i128_checks_overflow()
161 assert_eq!(None, cast::<f64, i128>(small_f)); in cast_to_i128_checks_overflow()
162 assert_eq!(None, cast::<f64, u128>(small_f)); in cast_to_i128_checks_overflow()
187 assert_eq!(Some($t::MIN), cast::<$f, $t>($t::MIN as $f));
188 assert_eq!(Some($t::MIN), cast::<$f, $t>(fmin));
189 assert_eq!(None, cast::<$f, $t>(small));
201 assert_eq!(Some(max), cast::<$f, $t>(max as $f));
202 assert_eq!(Some(max), cast::<$f, $t>(fmax));
203 assert_eq!(None, cast::<$f, $t>(large));
206 assert_eq!(None, cast::<$f, $t>($f::NAN));
207 assert_eq!(None, cast::<$f, $t>($f::INFINITY));
208 assert_eq!(None, cast::<$f, $t>($f::NEG_INFINITY));
259 assert_eq!(Some($f::MIN as $t), cast::<$f, $t>($f::MIN));
262 assert_eq!(Some($t::MIN), cast::<$f, $t>($f::MIN));
266 assert_eq!(Some($t::MIN), cast::<$f, $t>(min));
267 assert_eq!(None, cast::<$f, $t>(min - 1));
274 assert_eq!(Some($t::MAX), cast::<$f, $t>(max));
275 assert_eq!(None, cast::<$f, $t>(max + 1));
278 assert_eq!(Some($t::MAX), cast::<$f, $t>($f::MAX));
281 assert_eq!(Some($f::MAX as $t), cast::<$f, $t>($f::MAX));