numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Floor helper.
///
/// Contract (minimum): round toward negative infinity. Implementers must
/// document behavior for halfway cases (if applicable), NaN/∞ inputs, and
/// whether the result is exact or approximate.
pub trait Floor: Sized {
    fn floor(self) -> Self;
}

#[cfg(any(feature = "std", feature = "libm"))]
mod float_impls {
    use super::Floor;

    #[inline]
    fn floor_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::floorf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::floor(x)
        }
    }

    #[inline]
    fn floor_f64(x: f64) -> f64 {
        #[cfg(feature = "libm")]
        {
            libm::floor(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f64::floor(x)
        }
    }

    macro_rules! impl_floor_for_float {
        ($ty:ty, $fn:ident) => {
            impl Floor for $ty {
                fn floor(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_floor_for_float!(f32, floor_f32);
    impl_floor_for_float!(f64, floor_f64);
}