improve comments

This commit is contained in:
The8472 2019-11-21 13:44:28 +01:00
parent 290fe895ba
commit cc67c8eb91

View File

@ -2213,8 +2213,10 @@ where
sink.did_panic = false; sink.did_panic = false;
sink.dst sink.dst
} else { } else {
// use try-fold since it vectorizes better, does not take ownership and lets us thread the // use try-fold
// write pointer through its innards // - it vectorizes better
// - unlike most internal iteration methods methods it only takes a &mut self
// - lets us thread the write pointer through its innards and get it back in the end
iterator iterator
.try_fold::<_, _, Result<_, !>>(dst, move |mut dst, item| { .try_fold::<_, _, Result<_, !>>(dst, move |mut dst, item| {
unsafe { unsafe {
@ -2232,7 +2234,7 @@ where
let src = iterator.as_inner(); let src = iterator.as_inner();
// check if SourceIter and InPlaceIterable contracts were upheld. // check if SourceIter and InPlaceIterable contracts were upheld.
// but if they weren't we may not even make it to this point // caveat: if they weren't we may not even make it to this point
debug_assert_eq!(src_buf, src.buf.as_ptr()); debug_assert_eq!(src_buf, src.buf.as_ptr());
debug_assert!(dst as *const _ <= src.ptr, "InPlaceIterable contract violation"); debug_assert!(dst as *const _ <= src.ptr, "InPlaceIterable contract violation");
@ -2276,10 +2278,9 @@ impl<T> SpecFrom<T, IntoIter<T>> for Vec<T> {
} }
} }
// Further specialization potential once lattice specialization exists // Further specialization potential once
// and https://github.com/rust-lang/rust/issues/62645 has been solved: // https://github.com/rust-lang/rust/issues/62645 has been solved:
// This can be broadened to only require size and alignment equality between // T can be split into IN and OUT which only need to have the same size and alignment
// input and output Item types.
impl<T, I> SpecFrom<T, I> for Vec<T> impl<T, I> SpecFrom<T, I> for Vec<T>
where where
I: Iterator<Item = T> + InPlaceIterable + SourceIter<Source = IntoIter<T>>, I: Iterator<Item = T> + InPlaceIterable + SourceIter<Source = IntoIter<T>>,
@ -2396,6 +2397,8 @@ where
} }
impl<T> Vec<T> { impl<T> Vec<T> {
// leaf method to which various SpecFrom/SpecExtend implementations delegate when
// they have no further optimizations to apply
fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) { fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) {
// This is the case for a general iterator. // This is the case for a general iterator.
// //