4 ms·
It's not the case anymore.
by nynx 5y ago
It's not the case anymore.
- MauranKilom 5y agoOk, but why was it the case?
- ekidd 5y agoRust has two low-level "array" types: - &[Elem]: A "slice" of elements, represented as a pointer and a length. - [Elem; N]. A fixed-size array where the number of elements is known at compile time. This might be used for 2D or 3D coordinates, for example. Array slices have always supported arbitrary lengths. But arrays with fixed compile-time sizes are represented as entirely different types: it's an error to pass a [i32; 2] to a function that wants an [i32; 3]. The size of the fixed-size array is part of the type. And until very recently, Rust's type system didn't support defining methods on [Elem; N] that were generic over N. This is a feature that tends to be added later in many languages that support generics, not just Rust.
- rwmj 5y agoThanks, I think this is the clearest explanation in the thread.