NewBuffer: use vec! instead of resizing vec
This commit is contained in:
parent
31d269852c
commit
0cb78d5a8f
|
@ -41,10 +41,8 @@ where
|
|||
type BufferType = T;
|
||||
|
||||
fn new_buffer(default: Self::BufferType) -> Self {
|
||||
let mut v: Vec<T> = Vec::new();
|
||||
v.resize(SIZE, default);
|
||||
let temp = v.into_boxed_slice();
|
||||
unsafe { Box::from_raw(Box::into_raw(temp) as *mut [T; SIZE]) }
|
||||
let temp = vec![default; SIZE].into_boxed_slice();
|
||||
unsafe { Box::from_raw(Box::into_raw(temp).cast::<[T; SIZE]>()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue