EDIT: I realized the TryFrom is just implemented for Box<[T]> not Vec<T> but you can easily convert a Vec<T> to a Box<[T]>. I updated the code accordingly.
I you want to rely a bit less on the optimizer using `reserve_exact()` + `resize()` can be a good choice. I guess it could be worthwhile to add a helper method to std.
vec![0u8; 1024*1024].into_boxed_slice().try_into().unwrap()
isn't that terrible to use
her as a function:
fn calloc_buffer<const N: usize>() -> Box<[u8; N]> {
}I you want to rely a bit less on the optimizer using `reserve_exact()` + `resize()` can be a good choice. I guess it could be worthwhile to add a helper method to std.