Merge pull request #195 from AfoHT/clone_drop_fix

Fix the clone drop issue
This commit is contained in:
Emil Fresk 2021-03-02 15:45:15 +01:00 committed by GitHub
commit 304cd02cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -680,10 +680,19 @@ where
N: ArrayLength<T>,
{
fn clone(&self) -> Self {
Self {
vec: self.vec.clone(),
next: self.next,
let mut vec = Vec::new();
if self.next < self.vec.len() {
let s = unsafe {
slice::from_raw_parts(
(self.vec.0.buffer.as_ptr() as *const T).add(self.next),
self.vec.len() - self.next,
)
};
vec.extend_from_slice(s).ok();
}
Self { vec, next: 0 }
}
}