From c4b983baf8c6f774c91bc7a8b640d7d001d8f9c0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 6 Feb 2022 12:45:13 +0100 Subject: [PATCH] Implement ExactSizeIterator for the buffer adapter --- src/buffer.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/buffer.rs b/src/buffer.rs index 0025c46d..b3624594 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -92,8 +92,15 @@ impl<'outer, 'inner> Iterator for Samples<'outer, 'inner> { None } } + + fn size_hint(&self) -> (usize, Option) { + let remaining = self.buffers[0].len() - self.current_sample; + (remaining, Some(remaining)) + } } +impl<'outer, 'inner> ExactSizeIterator for Samples<'outer, 'inner> {} + /// An iterator over the channel data for a sample, yielded by [Samples]. pub struct Channels<'outer, 'inner> { /// The raw output buffers. @@ -124,4 +131,11 @@ impl<'outer, 'inner> Iterator for Channels<'outer, 'inner> { None } } + + fn size_hint(&self) -> (usize, Option) { + let remaining = self.buffers0.len() - self.current_channel; + (remaining, Some(remaining)) + } } + +impl<'outer, 'inner> ExactSizeIterator for Channels<'outer, 'inner> {}