@@ -2107,8 +2107,10 @@ where
2107
2107
sink. did_panic = false ;
2108
2108
sink. dst
2109
2109
} 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
2112
2114
iterator
2113
2115
. try_fold :: < _ , _ , Result < _ , !> > ( dst, move |mut dst, item| {
2114
2116
unsafe {
@@ -2126,7 +2128,7 @@ where
2126
2128
2127
2129
let src = iterator. as_inner ( ) ;
2128
2130
// 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
2130
2132
debug_assert_eq ! ( src_buf, src. buf. as_ptr( ) ) ;
2131
2133
debug_assert ! ( dst as * const _ <= src. ptr, "InPlaceIterable contract violation" ) ;
2132
2134
@@ -2171,10 +2173,9 @@ impl<T> SpecFrom<T, IntoIter<T>> for Vec<T> {
2171
2173
}
2172
2174
}
2173
2175
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
2178
2179
impl < T , I > SpecFrom < T , I > for Vec < T >
2179
2180
where
2180
2181
I : Iterator < Item = T > + InPlaceIterable + SourceIter < Source = IntoIter < T > > ,
@@ -2290,6 +2291,8 @@ where
2290
2291
}
2291
2292
2292
2293
impl < T > Vec < T > {
2294
+ // leaf method to which various SpecFrom/SpecExtend implementations delegate when
2295
+ // they have no further optimizations to apply
2293
2296
fn extend_desugared < I : Iterator < Item = T > > ( & mut self , mut iterator : I ) {
2294
2297
// This is the case for a general iterator.
2295
2298
//
0 commit comments