From 388788678538742c03e072aefb13851dcd6b228d Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 26 Nov 2022 19:20:40 -0600 Subject: [PATCH] angry at clippy for this --- src/primitives/one_or_many.rs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/primitives/one_or_many.rs b/src/primitives/one_or_many.rs index 98523ef..7455ca3 100644 --- a/src/primitives/one_or_many.rs +++ b/src/primitives/one_or_many.rs @@ -400,13 +400,7 @@ impl<'a, T> Iterator for Iter<'a, T> { fn count(self) -> usize { match self.0 { - Either::Left(opt) => { - if opt.is_some() { - 1 - } else { - 0 - } - } + Either::Left(opt) => opt.map_or(0, |_| 1), Either::Right(iter) => iter.count(), } } @@ -466,13 +460,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { fn count(self) -> usize { match self.0 { - Either::Left(opt) => { - if opt.is_some() { - 1 - } else { - 0 - } - } + Either::Left(opt) => opt.map_or(0, |_| 1), Either::Right(iter) => iter.count(), } } @@ -532,13 +520,7 @@ impl Iterator for IntoIter { fn count(self) -> usize { match self.0 { - Either::Left(opt) => { - if opt.is_some() { - 1 - } else { - 0 - } - } + Either::Left(opt) => opt.map_or(0, |_| 1), Either::Right(iter) => iter.count(), } }