numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Hypotenuse helper.
///
/// Contract (minimum): return sqrt(self^2 + other^2). Implementers must
/// document overflow behavior, handling of NaN/∞, and numerical stability.
pub trait Hypot: Sized {
    /// Returns sqrt(self^2 + other^2).
    fn hypot(self, other: Self) -> Self;
}

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

    #[inline]
    fn hypot_f32(x: f32, y: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::hypotf(x, y)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::hypot(x, y)
        }
    }

    #[inline]
    fn hypot_f64(x: f64, y: f64) -> f64 {
        #[cfg(feature = "libm")]
        {
            libm::hypot(x, y)
        }
        #[cfg(not(feature = "libm"))]
        {
            f64::hypot(x, y)
        }
    }

    macro_rules! impl_hypot_for_float {
        ($ty:ty, $fn:ident) => {
            impl Hypot for $ty {
                fn hypot(self, other: Self) -> Self {
                    $fn(self, other)
                }
            }
        };
    }

    impl_hypot_for_float!(f32, hypot_f32);
    impl_hypot_for_float!(f64, hypot_f64);
}