Skip to content

Commit

Permalink
Fix the clone drop issue
Browse files Browse the repository at this point in the history
  • Loading branch information
korken89 committed Mar 2, 2021
1 parent 4499eda commit 4ac126e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down

0 comments on commit 4ac126e

Please sign in to comment.