When to use Arrays and Vectors in Rust — Array[] vs Vectors<>
By Ugochukwu Chizaram Omumusinachi. Updated Thu Jan 30 2025What is the difference between arrays and vectors in Rust? The answer is: They are both fundamentally the same thing, trust me bro 🫠*. Same same but different.*
You see to understand the difference between rust arrays and vectors we have to look back into Data structures. What is an Array (or list if you come from a Python background)?
In short terms, an array is a contiguous data structure stored on the stack. Now if you did your homework you would know there a two major types of arrays, Dynamic and Static Arrays.
This article is not about Data Structures in general so I won’t go into details, but all you have to know is Dynamic arrays are simply static arrays with a bunch of wrappers to handle fluidity, in rust this wrapper is called a Vector.