Skip to content

Commit a524321

Browse files
committed
improve comments
1 parent c9fa7ce commit a524321

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/liballoc/vec.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,8 +2107,10 @@ where
21072107
sink.did_panic = false;
21082108
sink.dst
21092109
} else {
2110-
// use try-fold since it vectorizes better, does not take ownership and lets us thread the
2111-
// write pointer through its innards
2110+
// use try-fold
2111+
// - it vectorizes better
2112+
// - unlike most internal iteration methods methods it only takes a &mut self
2113+
// - lets us thread the write pointer through its innards and get it back in the end
21122114
iterator
21132115
.try_fold::<_, _, Result<_, !>>(dst, move |mut dst, item| {
21142116
unsafe {
@@ -2126,7 +2128,7 @@ where
21262128

21272129
let src = iterator.as_inner();
21282130
// check if SourceIter and InPlaceIterable contracts were upheld.
2129-
// but if they weren't we may not even make it to this point
2131+
// caveat: if they weren't we may not even make it to this point
21302132
debug_assert_eq!(src_buf, src.buf.as_ptr());
21312133
debug_assert!(dst as *const _ <= src.ptr, "InPlaceIterable contract violation");
21322134

@@ -2171,10 +2173,9 @@ impl<T> SpecFrom<T, IntoIter<T>> for Vec<T> {
21712173
}
21722174
}
21732175

2174-
// Further specialization potential once lattice specialization exists
2175-
// and https://github.com/rust-lang/rust/issues/62645 has been solved:
2176-
// This can be broadened to only require size and alignment equality between
2177-
// input and output Item types.
2176+
// Further specialization potential once
2177+
// https://github.com/rust-lang/rust/issues/62645 has been solved:
2178+
// T can be split into IN and OUT which only need to have the same size and alignment
21782179
impl<T, I> SpecFrom<T, I> for Vec<T>
21792180
where
21802181
I: Iterator<Item = T> + InPlaceIterable + SourceIter<Source = IntoIter<T>>,
@@ -2290,6 +2291,8 @@ where
22902291
}
22912292

22922293
impl<T> Vec<T> {
2294+
// leaf method to which various SpecFrom/SpecExtend implementations delegate when
2295+
// they have no further optimizations to apply
22932296
fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) {
22942297
// This is the case for a general iterator.
22952298
//

0 commit comments

Comments
 (0)