瀏覽代碼

Moved impl of `MulAdd`/`MulAddAssign` for `f32`/`f64` behind feature guard

Vincent Esche 7 年之前
父節點
當前提交
28be885481
共有 1 個文件被更改,包括 8 次插入20 次删除
  1. 8 20
      src/ops/mul_add.rs

+ 8 - 20
src/ops/mul_add.rs

@@ -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)
     }
 }