numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Cube root helper.
///
/// Contract (minimum): return a cube root of the input. Implementers must
/// document how they handle NaN/∞, precision/rounding behavior, and signed zero
/// conventions.
pub trait Cbrt: Sized {
    /// Returns the cube root of `self`.
    fn cbrt(self) -> Self;
}

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

    #[inline]
    fn cbrt_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::cbrtf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::cbrt(x)
        }
    }

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

    macro_rules! impl_cbrt_for_float {
        ($ty:ty, $fn:ident) => {
            impl Cbrt for $ty {
                fn cbrt(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_cbrt_for_float!(f32, cbrt_f32);
    impl_cbrt_for_float!(f64, cbrt_f64);
}