Re:Methods for Array Initialization in Rust (2018)
by chrismorgan on Monday May 24, 2021 @09:00AM
(#27263816)
(2018)
Some parts of this article are likely to be out of date, though I haven’t looked in detail (I’m just going to bed). Most significantly, the recent const generics stabilisations has shifted the balance of power and may have made some alternatives nicer. I do, however, note that [T; N]’s Default implementation is still limited to N ≤ 32, for technical reasons that haven’t yet been overcome. (https://github.com/rust-lang/rust/pull/74254 is relevant info that I’ve found on a quick search—I think the trouble is that [T; N] normally requires T: Default, but [T; 0] doesn’t, and this can’t be sorted out with the minimum const generics that has shipped. An unfortunate case of designing oneself into a corner by doing things that made perfect sense at the time.)
Some parts of this article are likely to be out of date, though I haven’t looked in detail (I’m just going to bed). Most significantly, the recent const generics stabilisations has shifted the balance of power and may have made some alternatives nicer. I do, however, note that [T; N]’s Default implementation is still limited to N ≤ 32, for technical reasons that haven’t yet been overcome. (https://github.com/rust-lang/rust/pull/74254 is relevant info that I’ve found on a quick search—I think the trouble is that [T; N] normally requires T: Default, but [T; 0] doesn’t, and this can’t be sorted out with the minimum const generics that has shipped. An unfortunate case of designing oneself into a corner by doing things that made perfect sense at the time.)