Vec
Explore how Rust handles dynamic collections using the Vec struct, which stores heap-allocated data. Understand the use of type parameters to specify element types and practice creating and modifying Vec instances using the vec! macro. This lesson helps you manage collections beyond fixed-size arrays.
We'll cover the following...
Arrays offer a fixed-size collection of values on the stack. Slices allow you to talk about any collection of values, regardless of where they’re stored or how many of them there are. What if we want to have a dynamic size? Just like we need a special struct String to hold heap-allocated strings, we need a special struct, Vec, to hold heap-allocated collections of arbitrary data.
I already bored you to death with the UTF-8 talk above. I’ll say this one much quicker, a String is a thin wrapper around a ...