3 ms·
i find the rust version way more readable; it's clear that it's an array of 1 (array of 2 (array of 3 u16s)), which corresponds to the way "multidimensional" ar
by zem 7y ago
i find the rust version way more readable; it's clear that it's an array of 1 (array of 2 (array of 3 u16s)), which corresponds to the way "multidimensional" arrays are actually laid out in c and friends.
- petschge 7y agoand why can't we write it like you just did, with outer to inner dimensions going from left to right, i.e. in the same order the indices go when we actually use elements?
- pitaj 7y agoArray 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...