numaxiom 0.0.2

Lightweight numeric marker traits for ranges/signs plus constants and ops; std by default, no_std optional.
Documentation
/// Natural logarithm helper.
pub trait Log: Sized {
    /// Returns ln(self).
    ///
    /// Implementations should document domain (e.g., positive inputs).
    fn ln(self) -> Self;
}

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

    fn ln_f32(x: f32) -> f32 {
        #[cfg(feature = "libm")]
        {
            libm::logf(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f32::ln(x)
        }
    }

    fn ln_f64(x: f64) -> f64 {
        #[cfg(feature = "libm")]
        {
            libm::log(x)
        }
        #[cfg(not(feature = "libm"))]
        {
            f64::ln(x)
        }
    }

    macro_rules! impl_log_for_float {
        ($ty:ty, $fn:ident) => {
            impl Log for $ty {
                fn ln(self) -> Self {
                    $fn(self)
                }
            }
        };
    }

    impl_log_for_float!(f32, ln_f32);
    impl_log_for_float!(f64, ln_f64);
}