2 ms·
Array filling shares syntax with array typing and array declaration: [0; 10] // ten-element array filled with zeros [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] // e
by pitaj 7y ago
Array filling shares syntax with array typing and array declaration:
[0; 10] // ten-element array filled with zeros
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] // equivalent array with ten zeroes typed out
[i32; 10] // type of ten-element i32 array
Because the "filling" syntax is optional, it makes sense to place it after the fill value. The array typing syntax follows. Essentially you specify the value and say "copy this X times" (it only works with types that implement Copy IIRC)
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=128743f4da38f5c3099795ef27dc95e0 https://play.rust-lang.org/?version=stable&mode=debug&editio...