fix sized deallocation for OwnedSlice
This commit is contained in:
parent
d1bd139251
commit
2fdad65a05
@ -58,9 +58,12 @@ pub fn from_vec(mut v: Vec<T>) -> OwnedSlice<T> {
|
||||
if len == 0 {
|
||||
OwnedSlice::empty()
|
||||
} else {
|
||||
// drop excess capacity to avoid breaking sized deallocation
|
||||
v.shrink_to_fit();
|
||||
|
||||
let p = v.as_mut_ptr();
|
||||
// we own the allocation now
|
||||
unsafe {mem::forget(v)}
|
||||
unsafe { mem::forget(v) }
|
||||
|
||||
OwnedSlice { data: p, len: len }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user