60
60
//! # O(1) collect
61
61
//!
62
62
//! The main iteration itself is further specialized when the iterator implements
63
- //! [`TrustedRandomAccessNoCoerce `] to let the optimizer see that it is a counted loop with a single
63
+ //! [`TrustedRandomAccess `] to let the optimizer see that it is a counted loop with a single
64
64
//! [induction variable]. This can turn some iterators into a noop, i.e. it reduces them from O(n) to
65
65
//! O(1). This particular optimization is quite fickle and doesn't always work, see [#79308]
66
66
//!
70
70
//! Since unchecked accesses through that trait do not advance the read pointer of `IntoIter`
71
71
//! this would interact unsoundly with the requirements about dropping the tail described above.
72
72
//! But since the normal `Drop` implementation of `IntoIter` would suffer from the same problem it
73
- //! is only correct for `TrustedRandomAccessNoCoerce ` to be implemented when the items don't
73
+ //! is only correct for `TrustedRandomAccess ` to be implemented when the items don't
74
74
//! have a destructor. Thus that implicit requirement also makes the specialization safe to use for
75
75
//! in-place collection.
76
76
//! Note that this safety concern is about the correctness of `impl Drop for IntoIter`,
134
134
//! }
135
135
//! vec.truncate(write_idx);
136
136
//! ```
137
- use core:: iter:: { InPlaceIterable , SourceIter , TrustedRandomAccessNoCoerce } ;
137
+ use core:: iter:: { InPlaceIterable , SourceIter , TrustedRandomAccess } ;
138
138
use core:: mem:: { self , ManuallyDrop } ;
139
139
use core:: ptr:: { self } ;
140
140
@@ -195,7 +195,7 @@ where
195
195
// itself once IntoIter goes out of scope.
196
196
// If the drop panics then we also leak any elements collected into dst_buf.
197
197
//
198
- // Note: This access to the source wouldn't be allowed by the TrustedRandomIteratorNoCoerce
198
+ // Note: This access to the source wouldn't be allowed by the TrustedRandomIterator
199
199
// contract (used by SpecInPlaceCollect below). But see the "O(1) collect" section in the
200
200
// module documenttation why this is ok anyway.
201
201
src. forget_allocation_drop_remaining ( ) ;
@@ -230,7 +230,7 @@ trait SpecInPlaceCollect<T, I>: Iterator<Item = T> {
230
230
/// collected. `end` is the last writable element of the allocation and used for bounds checks.
231
231
///
232
232
/// This method is specialized and one of its implementations makes use of
233
- /// `Iterator::__iterator_get_unchecked` calls with a `TrustedRandomAccessNoCoerce ` bound
233
+ /// `Iterator::__iterator_get_unchecked` calls with a `TrustedRandomAccess ` bound
234
234
/// on `I` which means the caller of this method must take the safety conditions
235
235
/// of that trait into consideration.
236
236
fn collect_in_place ( & mut self , dst : * mut T , end : * const T ) -> usize ;
@@ -256,7 +256,7 @@ where
256
256
257
257
impl < T , I > SpecInPlaceCollect < T , I > for I
258
258
where
259
- I : Iterator < Item = T > + TrustedRandomAccessNoCoerce ,
259
+ I : Iterator < Item = T > + TrustedRandomAccess ,
260
260
{
261
261
#[ inline]
262
262
fn collect_in_place ( & mut self , dst_buf : * mut T , end : * const T ) -> usize {
0 commit comments