@@ -2232,6 +2232,14 @@ impl<'a, T, const N: usize> Iterator for ArrayWindows<'a, T, N> {
22322232 fn last ( self ) -> Option < Self :: Item > {
22332233 self . v . last_chunk ( )
22342234 }
2235+
2236+ unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item {
2237+ // SAFETY: since the caller guarantees that `idx` is in bounds,
2238+ // which means that `idx` cannot overflow an `isize`, and the
2239+ // "slice" created by `cast_array` is a subslice of `self.v`
2240+ // thus is guaranteed to be valid for the lifetime `'a` of `self.v`.
2241+ unsafe { & * self . v . as_ptr ( ) . add ( idx) . cast_array ( ) }
2242+ }
22352243}
22362244
22372245#[ stable( feature = "array_windows" , since = "1.94.0" ) ]
@@ -2266,6 +2274,16 @@ unsafe impl<T, const N: usize> TrustedLen for ArrayWindows<'_, T, N> {}
22662274#[ stable( feature = "array_windows" , since = "1.94.0" ) ]
22672275impl < T , const N : usize > FusedIterator for ArrayWindows < ' _ , T , N > { }
22682276
2277+ #[ doc( hidden) ]
2278+ #[ unstable( feature = "trusted_random_access" , issue = "none" ) ]
2279+ unsafe impl < T , const N : usize > TrustedRandomAccess for ArrayWindows < ' _ , T , N > { }
2280+
2281+ #[ doc( hidden) ]
2282+ #[ unstable( feature = "trusted_random_access" , issue = "none" ) ]
2283+ unsafe impl < T , const N : usize > TrustedRandomAccessNoCoerce for ArrayWindows < ' _ , T , N > {
2284+ const MAY_HAVE_SIDE_EFFECT : bool = false ;
2285+ }
2286+
22692287/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a
22702288/// time), starting at the end of the slice.
22712289///
0 commit comments