From 52c3b56b9d8fe3814895b543288d05118b56d9f7 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Fri, 27 Oct 2023 08:51:09 +0200 Subject: [PATCH] `Tuple*Combination::fold`: avoid `unwrap` --- src/adaptors/mod.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index 802256542..b3d307a2a 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -767,12 +767,11 @@ macro_rules! impl_tuple_combination { F: FnMut(B, Self::Item) -> B, { let Self { c, item, mut iter } = self; - init = c - .map(|($($X),*,)| { - let z = item.clone().unwrap(); - (z, $($X),*) - }) - .fold(init, &mut f); + if let Some(z) = item.as_ref() { + init = c + .map(|($($X),*,)| (z.clone(), $($X),*)) + .fold(init, &mut f); + } while let Some(z) = iter.next() { let c: $P = iter.clone().into(); init = c