Skip to content

Commit 2706ae1

Browse files
committed
Add SAFETY comment to the TrustedLen impl of vec::Drain
1 parent 7ce1b3b commit 2706ae1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/alloc/src/vec/drain.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ impl<T, A: Allocator> ExactSizeIterator for Drain<'_, T, A> {
149149
}
150150

151151
#[unstable(feature = "trusted_len", issue = "37572")]
152+
// SAFETY: `Drain` simply forwards to the underlying slice iterator, which implements `TrustedLen`
153+
// so the required properties are all preserved.
152154
unsafe impl<T, A: Allocator> TrustedLen for Drain<'_, T, A> {}
153155

154156
#[stable(feature = "fused", since = "1.26.0")]

0 commit comments

Comments
 (0)