diff options
| author | Pazzaz <pazzaz.sundqvist@gmail.com> | 2018-08-15 18:01:42 +0200 |
|---|---|---|
| committer | Pazzaz <pazzaz.sundqvist@gmail.com> | 2018-08-15 18:01:42 +0200 |
| commit | 76625280b25bfe66d3a6e2c7e4c04726886fa7e1 (patch) | |
| tree | f198045a4b115aca6577ee340d1ef7c2b5b32e03 /src/liballoc/collections | |
| parent | ae0f25431129f87c271e13c87ecba629529f8723 (diff) | |
| download | rust-76625280b25bfe66d3a6e2c7e4c04726886fa7e1.tar.gz rust-76625280b25bfe66d3a6e2c7e4c04726886fa7e1.zip | |
Clarify unused_as_mut_slices
Diffstat (limited to 'src/liballoc/collections')
| -rw-r--r-- | src/liballoc/collections/vec_deque.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 95d4b918df3..297991b3976 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -208,11 +208,14 @@ impl<T> VecDeque<T> { let head = self.head; let tail = self.tail; let buf = self.buffer_as_mut_slice(); - if head == tail { + if head != tail { + // In buf, head..tail contains the VecDeque and tail..head is unused. + // So calling `ring_slices` with tail and head swapped returns unused slices. + RingSlices::ring_slices(buf, tail, head) + } else { + // Swapping doesn't help when head == tail. let (before, after) = buf.split_at_mut(head); (after, before) - } else { - RingSlices::ring_slices(buf, tail, head) } } |
