Just like the dynamic array in Chapter 4, Lists, Lists, More Lists, Vec<T> and VecDeque<T> are growable, list-like data structures with support for indexing and based on a heap-allocated array. Other than the previously implemented dynamic array, it is generic by default without any constraints for the generic type, allowing literally any type to be used.
Vec<T> aims to have as little overhead as possible, while providing a few guarantees. At its core, it is a triple of (pointer, length, capacity) that provides an API to modify these elements. The capacity is the amount of memory that is allocated to hold items, which means that it fundamentally differs from length, the number of elements currently held. In case a zero-sized type or no initial length is provided, Vec<T> won't actually allocate any memory. The pointer only points to the reserved area in memory that is encapsulated as a RawVec<T> structure.
The main drawback...