From 77031e7e083024aa6cb40e45726ac1ab554fde45 Mon Sep 17 00:00:00 2001 From: Aron Granberg Date: Fri, 2 Oct 2020 17:15:34 +0200 Subject: [PATCH 1/2] Add missing size_hint for Done source --- src/source/done.rs | 4 ++++ 1 file changed, 4 insertions(+) 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 From 1c376e879066aa1bab6d19842abf5cad78fc98f7 Mon Sep 17 00:00:00 2001 From: Aron Granberg Date: Fri, 2 Oct 2020 17:23:30 +0200 Subject: [PATCH 2/2] Fix SourcesQueueOutput::current_frame_len using upper bound instead of lower bound --- src/queue.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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.