Moved impl of `MulAdd`/`MulAddAssign` for `f32`/`f64` behind feature guard
This commit is contained in:
parent
830363024b
commit
28be885481
|
@ -33,29 +33,23 @@ pub trait MulAddAssign<A = Self, B = Self> {
|
|||
fn mul_add_assign(&mut self, a: A, b: B);
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl MulAdd<f32, f32> for f32 {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
||||
if cfg!(feature = "std") {
|
||||
f32::mul_add(self, a, b)
|
||||
} else {
|
||||
(self * a) + b
|
||||
}
|
||||
f32::mul_add(self, a, b)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl MulAdd<f64, f64> for f64 {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
||||
if cfg!(feature = "std") {
|
||||
f64::mul_add(self, a, b)
|
||||
} else {
|
||||
(self * a) + b
|
||||
}
|
||||
f64::mul_add(self, a, b)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,25 +68,19 @@ macro_rules! mul_add_impl {
|
|||
|
||||
mul_add_impl!(MulAdd for isize usize i8 u8 i16 u16 i32 u32 i64 u64);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl MulAddAssign<f32, f32> for f32 {
|
||||
#[inline]
|
||||
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
||||
if cfg!(feature = "std") {
|
||||
*self = f32::mul_add(*self, a, b)
|
||||
} else {
|
||||
*self = (*self * a) + b
|
||||
}
|
||||
*self = f32::mul_add(*self, a, b)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl MulAddAssign<f64, f64> for f64 {
|
||||
#[inline]
|
||||
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
||||
if cfg!(feature = "std") {
|
||||
*self = f64::mul_add(*self, a, b)
|
||||
} else {
|
||||
*self = (*self * a) + b
|
||||
}
|
||||
*self = f64::mul_add(*self, a, b)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue