We learnt about vectors Vec
and how we can define and initialize a vector. We also saw how we can use ::with_capacity(5)
in order to define a Vector which can reside on a stack memory.
We learnt about usize
which basically is nothing but the bit-size of your system. If you compile the Rust code on a 32-bit system
then the usize
would be 32 bits otherwise if you compile the Rust code on a 64-bit system
then the usize
would be 64 bits. You’d hardly find a system now a days which is lower than 32 bits
.
We learnt about the stack memory and how the program uses it to fetch and store variables passed along the function calls during the lifecycle of the program.
We also learnt about the heap memory and how the Rust program uses it to fetch and store dynamic length variables like Vectors.
I hope you liked this section about Rust Vectors. Please share your feedback in the comments section.
You can subscribe to my newsletter about The Rust Programming Language here. You can read about all the articles in this series here.