Use `Vec<T>` as the default container for a resizable sequence of values. It stores elements in contiguous, heap-allocated memory. Prefer it for a list of items; use `Box<T>` when you need to allocate a single item. section 4.9 section 5.10
A vector can be borrowed as a slice, `&[T]`, through `Deref`; a mutable borrow can similarly become `&mut [T]`. The slice has a fixed length, so it cannot resize the vector. The borrow checker also prevents resizing a vector while a borrowed slice remains in use. section 4.3.1
A slice blocks resizing
Given `let mut v = vec![1, 2, 3]; let slice = v.as_slice();`, calling `v.resize(10, 0)` before the last use of `slice` fails to compile: resizing needs a mutable borrow while the slice holds an immutable one. section 4.3.1
Capacity is measured in elements, not bytes, and can exceed length. An empty vector starts with zero capacity and allocates when elements are added; reaching capacity triggers growth. If you know the required size, start with `Vec::with_capacity(n)` to avoid repeated reallocations. That reserves space—it does not add elements. For a large vector retaining excess capacity, consider `shrink_to_fit()`, while weighing the cost of contiguous storage. section 11.2.1 section 11.7
Copying `Copy` elements
For equal-length source and destination sequences whose elements implement `Copy`, `copy_from_slice()` offers a fast copy path. In one release-mode benchmark copying 10 million `i32` values, it took about 0.0036 seconds versus about 0.025 seconds for a push-based loop; treat those timings as an example, not a guarantee. section 11.2.3
Start with `Vec` unless a specific access pattern or measured memory cost calls for another collection. `String` wraps `Vec<u8>`, and `BinaryHeap` uses a vector internally; `Vec<Box<T>>` is an option when storing large elements contiguously is a concern. section 4.3.2 section 4.3.3










