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);
|
fn mul_add_assign(&mut self, a: A, b: B);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
impl MulAdd<f32, f32> for f32 {
|
impl MulAdd<f32, f32> for f32 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
||||||
if cfg!(feature = "std") {
|
f32::mul_add(self, a, b)
|
||||||
f32::mul_add(self, a, b)
|
|
||||||
} else {
|
|
||||||
(self * a) + b
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
impl MulAdd<f64, f64> for f64 {
|
impl MulAdd<f64, f64> for f64 {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
fn mul_add(self, a: Self, b: Self) -> Self::Output {
|
||||||
if cfg!(feature = "std") {
|
f64::mul_add(self, a, b)
|
||||||
f64::mul_add(self, a, b)
|
|
||||||
} else {
|
|
||||||
(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);
|
mul_add_impl!(MulAdd for isize usize i8 u8 i16 u16 i32 u32 i64 u64);
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
impl MulAddAssign<f32, f32> for f32 {
|
impl MulAddAssign<f32, f32> for f32 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
||||||
if cfg!(feature = "std") {
|
*self = f32::mul_add(*self, a, b)
|
||||||
*self = f32::mul_add(*self, a, b)
|
|
||||||
} else {
|
|
||||||
*self = (*self * a) + b
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
impl MulAddAssign<f64, f64> for f64 {
|
impl MulAddAssign<f64, f64> for f64 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
fn mul_add_assign(&mut self, a: Self, b: Self) {
|
||||||
if cfg!(feature = "std") {
|
*self = f64::mul_add(*self, a, b)
|
||||||
*self = f64::mul_add(*self, a, b)
|
|
||||||
} else {
|
|
||||||
*self = (*self * a) + b
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue