diff --git a/src/queue.rs b/src/queue.rs index 8f9d63d..4db1654 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -132,10 +132,11 @@ where } // Try the size hint. - if let Some(val) = self.current.size_hint().1 { - if val < THRESHOLD && val != 0 { - return Some(val); - } + let (lower_bound, _) = self.current.size_hint(); + // The iterator default implementation just returns 0. + // That's a problematic value, so skip it. + if lower_bound > 0 { + return Some(lower_bound); } // Otherwise we use the constant value. diff --git a/src/source/done.rs b/src/source/done.rs index fb26713..d908d96 100644 --- a/src/source/done.rs +++ b/src/source/done.rs @@ -57,6 +57,10 @@ where } next } + + fn size_hint(&self) -> (usize, Option) { + self.input.size_hint() + } } impl Source for Done