Skip to content

Glossary: Rust in Practice

Vec::with_capacity

Also written: with_capacity

Creates a `Vec` with room for a known number of items, so it allocates once instead of growing step by step.

Where the book teaches it

Related terms

allocationhot loop