CVecTempl previously called Vec.clone_from_slice() on a
newly-allocated Vec, which immediately panics as
[T].clone_from_slice() requires that the Vec/target slice already
has the same length as the source slice. This should have been
Vec.extend_from_slice() which exhibits the correct behavior.
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.clone_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}