#![cfg_attr(
not(feature = "std"),
allow(dead_code, reason = "abs and copysign were added to core in 1.84")
)]
macro_rules! define_float_funcs {
($(
fn $name:ident(self $(,$arg:ident: $arg_ty:ty)*) -> $ret:ty
=> $lfname:ident;
)+) => {
#[cfg(not(feature = "std"))]
pub(crate) trait FloatFuncs : Sized {
$(fn $name(self $(,$arg: $arg_ty)*) -> $ret;)+
}
#[cfg(not(feature = "std"))]
impl FloatFuncs for f32 {
$(fn $name(self $(,$arg: $arg_ty)*) -> $ret {
#[cfg(feature = "libm")]
return libm::$lfname(self $(,$arg)*);
#[cfg(not(feature = "libm"))]
compile_error!("color requires either the `std` or `libm` feature")
})+
}
}
}
define_float_funcs! {
fn abs(self) -> Self => fabsf;
fn atan2(self, other: Self) -> Self => atan2f;
fn cbrt(self) -> Self => cbrtf;
fn ceil(self) -> Self => ceilf;
fn copysign(self, sign: Self) -> Self => copysignf;
fn floor(self) -> Self => floorf;
fn hypot(self, other: Self) -> Self => hypotf;
fn powf(self, n: Self) -> Self => powf;
fn round(self) -> Self => roundf;
fn sin_cos(self) -> (Self, Self) => sincosf;
fn sqrt(self) -> Self => sqrtf;
}