Skip to content

Commit a56db69

Browse files
committed
Adjust the safety comments on drain/into_iter_from
The safety contract for these methods is really about the validity of the given `RawIter` for this `RawTable`. Once that's established, the lifetime is no longer a concern, since `RawDrain<'_, T>` has a borrow and `RawIntoIter<T>` is a consuming owner.
1 parent e793bd2 commit a56db69

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/raw/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,12 +1073,10 @@ impl<T> RawTable<T> {
10731073
/// Returns an iterator which removes all elements from the table without
10741074
/// freeing the memory.
10751075
///
1076-
/// It is up to the caller to ensure that the `RawTable` outlives the `RawDrain`.
1077-
/// Because we cannot make the `next` method unsafe on the `RawDrain`,
1078-
/// we have to make the `drain` method unsafe.
1079-
///
10801076
/// Iteration starts at the provided iterator's current location.
1081-
/// You must ensure that the iterator covers all items that remain in the table.
1077+
///
1078+
/// It is up to the caller to ensure that the iterator is valid for this
1079+
/// `RawTable` and covers all items that remain in the table.
10821080
#[cfg_attr(feature = "inline-more", inline)]
10831081
pub unsafe fn drain_iter_from(&mut self, iter: RawIter<T>) -> RawDrain<'_, T> {
10841082
debug_assert_eq!(iter.len(), self.len());
@@ -1092,12 +1090,10 @@ impl<T> RawTable<T> {
10921090

10931091
/// Returns an iterator which consumes all elements from the table.
10941092
///
1095-
/// It is up to the caller to ensure that the `RawTable` outlives the `RawIntoIter`.
1096-
/// Because we cannot make the `next` method unsafe on the `RawIntoIter`,
1097-
/// we have to make the `into_iter_from` method unsafe.
1098-
///
10991093
/// Iteration starts at the provided iterator's current location.
1100-
/// You must ensure that the iterator covers all items that remain in the table.
1094+
///
1095+
/// It is up to the caller to ensure that the iterator is valid for this
1096+
/// `RawTable` and covers all items that remain in the table.
11011097
pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T> {
11021098
debug_assert_eq!(iter.len(), self.len());
11031099

0 commit comments

Comments
 (0)