3 ms·
Array sizes are static and can be used for optimization, that's a very significant advantage in some situations. As an example, if I'm emulating some RAM module
by simias 6y ago
Array sizes are static and can be used for optimization, that's a very significant advantage in some situations. As an example, if I'm emulating some RAM module of a console, I'd much rather use a cheap [u8; RAM_LEN] than a Vec that would incur all kinds of runtime checks for nothing.
Unfortunately there are many limitations with arrays in Rust at the moment, which make it more annoying than it should be. Generics over the array size is one of them, although unfortunately there are others such as https://github.com/rust-lang/rust/issues/53827 https://github.com/rust-lang/rust/issues/53827