Loading RustViz Engine...
Allocate stack buffer of unknown size without paying zero-initialization overhead.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::mem::MaybeUninit;
pub fn create_initialized_array(val: i32) -> [i32; 100] {
let mut data: [MaybeUninit<i32>; 100] = unsafe {
MaybeUninit::uninit().assume_init()
};
for elem in &mut data[..] {
elem.write(val);
}
unsafe { std::mem::transmute(data) }
}