From 3ef76ab9e4c484185875da7739b0796cb7b37f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20L=C3=B6schner?= Date: Tue, 13 Aug 2019 09:04:41 +0200 Subject: [PATCH] More elegant initial value for xcmp --- src/base/ops.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/base/ops.rs b/src/base/ops.rs index 758c1464..3566a2b5 100644 --- a/src/base/ops.rs +++ b/src/base/ops.rs @@ -871,10 +871,7 @@ impl> Matrix { fn xcmp(&self, abs: impl Fn(N) -> N2, ordering: Ordering) -> N2 where N2: Scalar + PartialOrd + Zero { let mut iter = self.iter(); - let mut max = match iter.next() { - Some(first) => abs(*first), - None => { return N2::zero(); } - }; + let mut max = iter.next().cloned().map_or(N2::zero(), &abs); for e in iter { let ae = abs(*e);