numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Round-to-nearest helper.
///
/// Contract (minimum): round to the nearest representable value. Implementers
/// must document tie-breaking rules, behavior for NaN/∞, and whether the result
/// is exact or approximate.
pub trait Round: Sized {
    fn round(self) -> Self;
}

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

    #[inline]
    fn round_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::roundf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::round(x)
        }
    }

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

    macro_rules! impl_round_for_float {
        ($ty:ty, $fn:ident) => {
            impl Round for $ty {
                fn round(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_round_for_float!(f32, round_f32);
    impl_round_for_float!(f64, round_f64);
}