traiter/numbers/
floor.rs

1pub trait Floor {
2    type Output;
3
4    /// Returns floor of a number.
5    ///
6    #[cfg_attr(
7        feature = "std",
8        doc = r##"
9```
10use traiter::numbers::Floor;
11// floating point numbers
12assert_eq!(Floor::floor(-1.5_f32), -2.0_f32);
13assert_eq!(Floor::floor(0.0_f32), 0.0_f32);
14assert_eq!(Floor::floor(1.5_f32), 1.0_f32);
15```
16"##
17    )]
18    fn floor(self) -> Self::Output;
19}
20
21macro_rules! float_floor_impl {
22    ($($float:ty)*) => ($(
23        impl Floor for $float {
24            type Output = Self;
25
26            #[inline(always)]
27            fn floor(self) -> Self::Output {
28                <$float>::floor(self)
29            }
30        }
31    )*)
32}
33
34#[cfg(feature = "std")]
35float_floor_impl!(f32 f64);