Skip to content

Commit 8d3554c

Browse files
committed
Don't drop values in other, just move the tail
1 parent 894c9ca commit 8d3554c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,7 @@ impl<T> VecDeque<T> {
18591859
// Guarantees there is space in `self` for `other`.
18601860
self.reserve(src_total);
18611861

1862-
let new_head = {
1862+
self.head = {
18631863
let original_head = self.head;
18641864

18651865
// The goal is to copy all values from `other` into `self`. To avoid any
@@ -1988,12 +1988,8 @@ impl<T> VecDeque<T> {
19881988
}
19891989
};
19901990

1991-
// Up until this point we are in a bad state as some values
1992-
// exist in both `self` and `other`. To preserve panic safety
1993-
// it is important we clear the old values from `other`...
1994-
other.clear();
1995-
// and that we update `head` as the last step, making the values accessible in `self`.
1996-
self.head = new_head;
1991+
// Some values now exist in both `other` and `self` but are made inaccessible in `other`.
1992+
other.tail = other.head;
19971993
}
19981994

19991995
/// Retains only the elements specified by the predicate.

0 commit comments

Comments
 (0)