mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-25 00:02:22 +00:00
convert to resize_with
This commit is contained in:
parent
a2baf0abb3
commit
436abe3e89
@ -91,7 +91,7 @@ pub fn try_zeroed_slice_box<T: Zeroable>(
|
||||
if size_of::<T>() == 0 {
|
||||
// This will not allocate but simple create a dangling slice pointer.
|
||||
let mut vec = Vec::with_capacity(length);
|
||||
vec.resize(length, T::zeroed());
|
||||
vec.resize_with(length, || T::zeroed());
|
||||
return Ok(vec.into_boxed_slice());
|
||||
}
|
||||
if length == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user