From 726b8eeecff9173abbefd1c775f2cbad44b4f641 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 16 Nov 2020 15:17:10 +0100 Subject: [PATCH] clippy: fix or_fun_call warnings --- src/base/construction.rs | 2 +- src/base/interpolation.rs | 2 +- src/base/min_max.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base/construction.rs b/src/base/construction.rs index 7ac24306..c740ce88 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -238,7 +238,7 @@ where SB: Storage, { assert!(!columns.is_empty(), "At least one column must be given."); - let ncols = C::try_to_usize().unwrap_or(columns.len()); + let ncols = C::try_to_usize().unwrap_or_else(|| columns.len()); let nrows = columns[0].len(); assert!( columns.len() == ncols, diff --git a/src/base/interpolation.rs b/src/base/interpolation.rs index faa630d9..afd3ccc7 100644 --- a/src/base/interpolation.rs +++ b/src/base/interpolation.rs @@ -81,7 +81,7 @@ impl> Unit> { { // TODO: the result is wrong when self and rhs are collinear with opposite direction. self.try_slerp(rhs, t, N::default_epsilon()) - .unwrap_or(Unit::new_unchecked(self.clone_owned())) + .unwrap_or_else(|| Unit::new_unchecked(self.clone_owned())) } /// Computes the spherical linear interpolation between two unit vectors. diff --git a/src/base/min_max.rs b/src/base/min_max.rs index 90af0142..0bddd4b0 100644 --- a/src/base/min_max.rs +++ b/src/base/min_max.rs @@ -57,7 +57,7 @@ impl> Matrix { N: SimdPartialOrd + Zero, { self.fold_with( - |e| e.map(|e| e.inlined_clone()).unwrap_or(N::zero()), + |e| e.map(|e| e.inlined_clone()).unwrap_or_else(N::zero), |a, b| a.simd_max(b.inlined_clone()), ) } @@ -75,7 +75,7 @@ impl> Matrix { N: Zero + SimdPartialOrd + SimdSigned, { self.fold_with( - |e| e.map(|e| e.simd_abs()).unwrap_or(N::zero()), + |e| e.map(|e| e.simd_abs()).unwrap_or_else(N::zero), |a, b| a.simd_min(b.simd_abs()), ) } @@ -97,7 +97,7 @@ impl> Matrix { self.fold_with( |e| { e.map(|e| e.simd_norm1()) - .unwrap_or(N::SimdRealField::zero()) + .unwrap_or_else(N::SimdRealField::zero) }, |a, b| a.simd_min(b.simd_norm1()), ) @@ -117,7 +117,7 @@ impl> Matrix { N: SimdPartialOrd + Zero, { self.fold_with( - |e| e.map(|e| e.inlined_clone()).unwrap_or(N::zero()), + |e| e.map(|e| e.inlined_clone()).unwrap_or_else(N::zero), |a, b| a.simd_min(b.inlined_clone()), ) }