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 fc6664c commit 9beb753Copy full SHA for 9beb753
src/lib.rs
@@ -600,12 +600,15 @@ impl<A: Array> ArrayVec<A> {
600
fn drain_range(&mut self, start: usize, end: usize) -> Drain<A>
601
{
602
let len = self.len();
603
- // bounds check happens here
+
604
+ // bounds check happens here (before length is changed!)
605
let range_slice: *const _ = &self[start..end];
606
607
+ // Calling `set_len` creates a fresh and thus unique mutable references, making all
608
+ // older aliases we created invalid. So we cannot call that function.
609
+ self.len = Index::from(start);
610
611
unsafe {
- // set self.vec length's to start, to be safe in case Drain is leaked
- self.set_len(start);
612
Drain {
613
tail_start: end,
614
tail_len: len - end,
0 commit comments