pub trait Abs {
type Output;
#[cfg_attr(
feature = "std",
doc = r##"
// floating point numbers
assert_eq!(Abs::abs(-1.0_f32), 1.0_f32);
assert_eq!(Abs::abs(0.0_f32), 0.0_f32);
assert_eq!(Abs::abs(1.0_f32), 1.0_f32);
"##
)]
fn abs(self) -> Self::Output;
}
macro_rules! number_abs_impl {
($($number:ty)*) => ($(
impl Abs for $number {
type Output = Self;
#[inline(always)]
fn abs(self) -> Self::Output {
<$number>::abs(self)
}
}
)*)
}
#[cfg(feature = "std")]
number_abs_impl!(f32 f64);
number_abs_impl!(i8 i16 i32 i64 i128 isize);