初始化从0到N的连续整数的数组的最简单形式是什么?
我有这段代码,但是我认为惯用的Rust看起来会更简单:
const NUM: u32 = 8;
fn main() {
let mut int_list: [u32; NUM as usize] = [0; NUM as usize];
for i in 0..NUM {
int_list[i as usize] = i;
}
println!("data: {:?}", int_list);
}