pub trait Tan: Sized {
fn tan(self) -> Self;
}
#[cfg(any(feature = "std", feature = "libm"))]
mod float_impls {
use super::Tan;
#[inline]
fn tan_f32(x: f32) -> f32 {
#[cfg(feature = "libm")]
{
libm::tanf(x)
}
#[cfg(not(feature = "libm"))]
{
f32::tan(x)
}
}
#[inline]
fn tan_f64(x: f64) -> f64 {
#[cfg(feature = "libm")]
{
libm::tan(x)
}
#[cfg(not(feature = "libm"))]
{
f64::tan(x)
}
}
macro_rules! impl_tan_for_float {
($ty:ty, $fn:ident) => {
impl Tan for $ty {
fn tan(self) -> Self {
$fn(self)
}
}
};
}
impl_tan_for_float!(f32, tan_f32);
impl_tan_for_float!(f64, tan_f64);
}