numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Exponential helper.
///
/// Contract (minimum): compute `e^self`. Implementers must document overflow
/// behavior, handling of NaN/∞, and any precision/rounding caveats.
pub trait Exp: Sized {
    /// Returns e^(self).
    fn exp(self) -> Self;
}

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

    #[cfg(any(feature = "std", feature = "libm"))]
    #[inline]
    fn exp_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::expf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::exp(x)
        }
    }

    #[cfg(any(feature = "std", feature = "libm"))]
    #[inline]
    fn exp_f64(x: f64) -> f64 {
        #[cfg(feature = "libm")]
        {
            libm::exp(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f64::exp(x)
        }
    }

    macro_rules! impl_exp_for_float {
        ($ty:ty, $fn:ident) => {
            impl Exp for $ty {
                fn exp(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_exp_for_float!(f32, exp_f32);
    impl_exp_for_float!(f64, exp_f64);
}