pub trait Atan2: Sized {
fn atan2(self, other: Self) -> Self;
}
#[cfg(any(feature = "std", feature = "libm"))]
mod float_impls {
use super::Atan2;
#[inline]
fn atan2_f32(y: f32, x: f32) -> f32 {
#[cfg(feature = "libm")]
{
libm::atan2f(y, x)
}
#[cfg(not(feature = "libm"))]
{
f32::atan2(y, x)
}
}
#[inline]
fn atan2_f64(y: f64, x: f64) -> f64 {
#[cfg(feature = "libm")]
{
libm::atan2(y, x)
}
#[cfg(not(feature = "libm"))]
{
f64::atan2(y, x)
}
}
macro_rules! impl_atan2_for_float {
($ty:ty, $fn:ident) => {
impl Atan2 for $ty {
fn atan2(self, other: Self) -> Self {
$fn(self, other)
}
}
};
}
impl_atan2_for_float!(f32, atan2_f32);
impl_atan2_for_float!(f64, atan2_f64);
}