diff options
| author | Pazzaz <pazzaz.sundqvist@gmail.com> | 2018-08-14 20:54:25 +0200 |
|---|---|---|
| committer | Pazzaz <pazzaz.sundqvist@gmail.com> | 2018-08-14 20:54:25 +0200 |
| commit | 8d3554c48d4f055654807f617609151cfcc7a81d (patch) | |
| tree | 31ee22c9806ee77291d074f8b0de34ac79424c17 /src/liballoc/collections | |
| parent | 894c9ca1a7e8265e0d9e8453f1d236293b6103b2 (diff) | |
| download | rust-8d3554c48d4f055654807f617609151cfcc7a81d.tar.gz rust-8d3554c48d4f055654807f617609151cfcc7a81d.zip | |
Don't drop values in other, just move the tail
Diffstat (limited to 'src/liballoc/collections')
| -rw-r--r-- | src/liballoc/collections/vec_deque.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 7f4fbb99c22..b66bb82bc37 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -1859,7 +1859,7 @@ impl<T> VecDeque<T> { // Guarantees there is space in `self` for `other`. self.reserve(src_total); - let new_head = { + self.head = { let original_head = self.head; // The goal is to copy all values from `other` into `self`. To avoid any @@ -1988,12 +1988,8 @@ impl<T> VecDeque<T> { } }; - // Up until this point we are in a bad state as some values - // exist in both `self` and `other`. To preserve panic safety - // it is important we clear the old values from `other`... - other.clear(); - // and that we update `head` as the last step, making the values accessible in `self`. - self.head = new_head; + // Some values now exist in both `other` and `self` but are made inaccessible in `other`. + other.tail = other.head; } /// Retains only the elements specified by the predicate. |
