|
|
|
|
|
by Denvercoder9
232 days ago
|
|
> Using Vec for arrays is also annoying, repeating the mistake from C++. Neither Rust nor C++ uses vectors as array, they're distinct things. An array is a fixed-size object, which never allocates and its elements thus always retain their memory address. In Rust they're `[T; N]`, in C++ `T[N]` or more recently `std::array<T, N>`. A vector on the other hand is dynamically sized object, that may (re)allocate to accomodate new elements, and the address of their elements can change. In Rust they're `Vec<T>`; in C++ `std::vector<T>`. |
|