assert that SourceIter requirements have not been violated by the pipeline

This commit is contained in:
The8472 2019-11-15 01:27:41 +01:00
parent 2a327394e4
commit 73a982e9ec

View File

@ -2131,12 +2131,14 @@ fn from_into_iter_source<T, I>(mut iterator: I) -> Vec<T>
I: Iterator<Item = T> + InPlaceIterable + SourceIter<Source = IntoIter<T>>,
{
let mut insert_pos = 0;
let original_ptr = iterator.as_inner().buf.as_ptr();
// FIXME: how to drop values written into source when iteration panics?
// tail already gets cleaned by IntoIter::drop
while let Some(item) = iterator.next() {
let source_iter = iterator.as_inner();
let src_buf = source_iter.buf.as_ptr();
debug_assert_eq!(original_ptr, src_buf);
let src_idx = source_iter.ptr;
unsafe {
let dst = src_buf.offset(insert_pos as isize);