From 28be8854815b5ec8fdf1513df3910b54a4763e49 Mon Sep 17 00:00:00 2001 From: Vincent Esche Date: Wed, 18 Apr 2018 10:31:37 +0200 Subject: [PATCH] Moved impl of `MulAdd`/`MulAddAssign` for `f32`/`f64` behind feature guard --- src/ops/mul_add.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/ops/mul_add.rs b/src/ops/mul_add.rs index 4b3ca2a..9a2a2cf 100644 --- a/src/ops/mul_add.rs +++ b/src/ops/mul_add.rs @@ -33,29 +33,23 @@ pub trait MulAddAssign { fn mul_add_assign(&mut self, a: A, b: B); } +#[cfg(feature = "std")] impl MulAdd 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 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 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 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) } }