From fa50056fce127508b9aceb0cbbe64f610cbbf294 Mon Sep 17 00:00:00 2001 From: Devon Hollowood Date: Thu, 27 Oct 2022 18:20:50 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com> --- stdlib/src/math.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stdlib/src/math.rs b/stdlib/src/math.rs index 982148a8c..31571eb1a 100644 --- a/stdlib/src/math.rs +++ b/stdlib/src/math.rs @@ -331,7 +331,7 @@ mod math { }; let mut norm = v .iter() - .cloned() + .copied() .map(|x| x / scale) .reduce(accurate_hypot) .unwrap_or_default(); @@ -342,9 +342,8 @@ mod math { // approximation of the square root of that to `norm`. let correction = v .iter() - .cloned() - .map(|x| x / scale) - .map(|x| x * x) + .copied() + .map(|x| (x / scale).pow(2)) .chain(std::iter::once(-norm * norm)) .tree_fold1(std::ops::Add::add) .unwrap();