numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Cosine helper.
///
/// Contract (minimum): return the cosine of the input. Implementers must
/// document behavior for NaN/∞ inputs and any accuracy guarantees.
pub trait Cos: Sized {
    fn cos(self) -> Self;
}

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

    #[inline]
    fn cos_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::cosf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::cos(x)
        }
    }

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

    macro_rules! impl_cos_for_float {
        ($ty:ty, $fn:ident) => {
            impl Cos for $ty {
                fn cos(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_cos_for_float!(f32, cos_f32);
    impl_cos_for_float!(f64, cos_f64);
}