pub fn get_mid<T>(a: T, b: T) -> T
Expand description
Returns the average of two numbers; works with at least all integral and floating point types
assert_eq!(get_mid(0, 10), 5);
assert_eq!(get_mid(0.0, 10.0), 5.0);
assert_eq!(get_mid(-10.0, 10.0), 0.0);
assert_eq!(get_mid(i16::MIN, i16::MAX), -1);
assert_eq!(get_mid(u8::MIN, u8::MAX), 127);
assert!(get_mid(f32::NAN, f32::NAN).is_nan());
assert!(get_mid(f32::NEG_INFINITY, f32::INFINITY).is_nan());