1
0
Fork 0

Implement ExactSizeIterator for the buffer adapter

This commit is contained in:
Robbert van der Helm 2022-02-06 12:45:13 +01:00
parent 2486368d08
commit c4b983baf8

View file

@ -92,8 +92,15 @@ impl<'outer, 'inner> Iterator for Samples<'outer, 'inner> {
None None
} }
} }
fn size_hint(&self) -> (usize, Option<usize>) {
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]. /// An iterator over the channel data for a sample, yielded by [Samples].
pub struct Channels<'outer, 'inner> { pub struct Channels<'outer, 'inner> {
/// The raw output buffers. /// The raw output buffers.
@ -124,4 +131,11 @@ impl<'outer, 'inner> Iterator for Channels<'outer, 'inner> {
None None
} }
} }
fn size_hint(&self) -> (usize, Option<usize>) {
let remaining = self.buffers0.len() - self.current_channel;
(remaining, Some(remaining))
}
} }
impl<'outer, 'inner> ExactSizeIterator for Channels<'outer, 'inner> {}