mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-26 20:10:24 +00:00
Fix the clone drop issue
This commit is contained in:
parent
4499eda03d
commit
4ac126e54c
15
src/vec.rs
15
src/vec.rs
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user