Fix bug in ArrayVec::extend_from_slice
Currently the source slice must be the exact length to fill the array to max capacity, this is an unnecessary restriction since an `ArrayVec` is a variable sized data structure. Set the destination slice to be the same length as the source slice (still maintain capacity checks).
This commit is contained in:
parent
cfb53c7866
commit
798c9cff1c
|
@ -78,7 +78,7 @@ mod safety_boundary {
|
||||||
assert!(new_len <= CAP, "buffer overflow");
|
assert!(new_len <= CAP, "buffer overflow");
|
||||||
// SAFETY: MaybeUninit<T> has the same layout as T
|
// SAFETY: MaybeUninit<T> has the same layout as T
|
||||||
let slice = unsafe { &*(slice as *const _ as *const [MaybeUninit<T>]) };
|
let slice = unsafe { &*(slice as *const _ as *const [MaybeUninit<T>]) };
|
||||||
self.data[self.len..].copy_from_slice(slice);
|
self.data[self.len..new_len].copy_from_slice(slice);
|
||||||
self.len = new_len;
|
self.len = new_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue