We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae0f254 commit 7662528Copy full SHA for 7662528
src/liballoc/collections/vec_deque.rs
@@ -208,11 +208,14 @@ impl<T> VecDeque<T> {
208
let head = self.head;
209
let tail = self.tail;
210
let buf = self.buffer_as_mut_slice();
211
- if head == tail {
+ if head != tail {
212
+ // In buf, head..tail contains the VecDeque and tail..head is unused.
213
+ // So calling `ring_slices` with tail and head swapped returns unused slices.
214
+ RingSlices::ring_slices(buf, tail, head)
215
+ } else {
216
+ // Swapping doesn't help when head == tail.
217
let (before, after) = buf.split_at_mut(head);
218
(after, before)
- } else {
- RingSlices::ring_slices(buf, tail, head)
219
}
220
221
0 commit comments