Fix issue when calling `buffer.samples()` multiple times with the same buffer

This commit is contained in:
Pierre Krieger 2014-12-15 15:48:30 +01:00
parent 6becac9780
commit 5c6fa4384f
1 changed files with 3 additions and 1 deletions

View File

@ -36,7 +36,7 @@ pub struct Buffer<'a, T> {
}
/// Iterator over the samples of the buffer.
pub struct SamplesIter<'a, 'b, T: 'b>(&'b mut uint, std::slice::MutItems<'b, T>);
pub struct SamplesIter<'a, 'b, T: 'b>(&'b mut uint, std::iter::Skip<std::slice::MutItems<'b, T>>);
struct RequiredConversion<T> {
intermediate_buffer: Vec<T>,
@ -177,6 +177,8 @@ impl<'a, T> Buffer<'a, T> {
self.target.as_mut().unwrap().get_buffer().iter_mut()
};
let iter = iter.skip(self.elements_written);
SamplesIter(&mut self.elements_written, iter)
}
}