Skip to content

Commit 9989334

Browse files
committed
Add SAFETY comment for the TrustedRandomAccess impl of iter::Fuse
1 parent 7ce1b3b commit 9989334

File tree

1 file changed

+5
-0
lines changed
  • library/core/src/iter/adapters

1 file changed

+5
-0
lines changed

library/core/src/iter/adapters/fuse.rs

+5
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ where
184184

185185
#[doc(hidden)]
186186
#[unstable(feature = "trusted_random_access", issue = "none")]
187+
// SAFETY: `TrustedRandomAccess` requires that `size_hint()` must be exact and cheap to call, and
188+
// `Iterator::__iterator_get_unchecked()` must be implemented accordingly.
189+
//
190+
// This is safe to implement as `Fuse` is just forwarding these to the wrapped iterator `I`, which
191+
// preserves these properties.
187192
unsafe impl<I> TrustedRandomAccess for Fuse<I>
188193
where
189194
I: TrustedRandomAccess,

0 commit comments

Comments
 (0)