Creating an array with the same value
examples/arrays/array-of-the-same/src/main.rs
fn main() { let counter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; println!("{} {:?}", counter.len(), counter); let counter = [0; 10]; println!("{} {:?}", counter.len(), counter); let answer = [42; 4]; println!("{} {:?}", answer.len(), answer); }
10 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 10 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 4 [42, 42, 42, 42]