Is there a better ( and stable ) way of initializing long slice behind the box?
let dst_buffer = Box::<[f32]>::new_zeroed_slice(1024);
let mut dst_buffer = unsafe { dst_buffer.assume_init() };
Is there a better ( and stable ) way of initializing long slice behind the box?
let dst_buffer = Box::<[f32]>::new_zeroed_slice(1024);
let mut dst_buffer = unsafe { dst_buffer.assume_init() };
let mut dst_buffer = vec![0_f32; 1024].into_boxed_slice();
should work fine.
Thanks, but 1024
is not constant. It is not known at compile-time variable. Sorry for confusing.
Well, the length in the vec![x; N]
macro isn't constant either.
Edit: demonstration; though now, both functions no longer produce exactly the same assembly. (They did with the 1024
in place.) But they shouldn't be different performance-wise anyways.
Is not N constant?
Fix the typo, please
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.