Skip to content

Commit 1750c7b

Browse files
committed
Clarify documentation
1 parent dad049c commit 1750c7b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

library/alloc/src/vec/in_place_collect.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,10 @@ where
194194
);
195195
}
196196

197-
// Drop any remaining values at the tail of the source but prevent drop of the allocation
198-
// itself once IntoIter goes out of scope.
199-
// If the drop panics then we also try to drop the destination buffer and its elements.
197+
// The ownership of the allocation and the new `T` values is temporarily moved into `dst_guard`.
200198
// This is safe because `forget_allocation_drop_remaining` immediately forgets the allocation
201-
// and won't panic before that.
199+
// before any panic can occur in order to avoid any double free, and then proceeds to drop
200+
// any remaining values at the tail of the source.
202201
//
203202
// Note: This access to the source wouldn't be allowed by the TrustedRandomIteratorNoCoerce
204203
// contract (used by SpecInPlaceCollect below). But see the "O(1) collect" section in the

0 commit comments

Comments
 (0)