We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Product::size_hint
1 parent 8d07f6b commit bf2b012Copy full SHA for bf2b012
src/adaptors/mod.rs
@@ -365,15 +365,13 @@ where
365
}
366
367
fn size_hint(&self) -> (usize, Option<usize>) {
368
- let has_cur = matches!(self.a_cur, Some(Some(_))) as usize;
369
// Not ExactSizeIterator because size may be larger than usize
370
- let (b_min, b_max) = self.b.size_hint();
371
-
372
// Compute a * b_orig + b for both lower and upper bound
373
- size_hint::add(
374
- size_hint::mul(self.a.size_hint(), self.b_orig.size_hint()),
375
- (b_min * has_cur, b_max.map(move |x| x * has_cur)),
376
- )
+ let mut sh = size_hint::mul(self.a.size_hint(), self.b_orig.size_hint());
+ if matches!(self.a_cur, Some(Some(_))) {
+ sh = size_hint::add(sh, self.b.size_hint());
+ }
+ sh
377
378
379
fn fold<Acc, G>(self, mut accum: Acc, mut f: G) -> Acc
0 commit comments