Rust Data StructuresLesson 24Free preview
Rust Vectors
This lesson is part of Rust · All levels
Summary
This lesson discusses Vectors (Vec<T>) which is the most commonly used dynamic array in Rust. Vectors store their elements sequentially in memory heap, so that their size can be increased or decreased as the program runs. The developer will learn the operations of push, pop, and the safe reading of the elements.
Key points
- Vectors store many values of the same type in the memory heap
- Its size can grow or shrink dynamically
- Adding new elements is done using the '.push()' method
- Reading elements can use direct index or the safe method '.get() ' that returns the Option
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.