1/6

Vec<T> is a contiguous, growable array. Its costs are worth knowing exactly:

| operation | cost | | --- | --- | | push / pop at the end | O(1) amortised | | insert / remove at the front | O(n) — everything shifts | | index | O(1) |

"Amortised" covers the growth: when the buffer is full, Vec allocates a larger one (typically double) and copies everything across. Averaged over many pushes that is O(1), but any individual push can be the expensive one.