The guarantee is a floor
A vector’s length counts its elements. Its capacity counts how many elements it can hold without reallocating. Those values serve different purposes: spare capacity leaves room for future elements, while the length tells you which elements are already present. Rust documents this distinction in its capacity and reallocation guide.
Calling vec.reserve(additional) ensures that the resulting capacity is at least vec.len() + additional. The argument describes room for additional elements, beyond the current length. It is not a target capacity. If the vector already has enough capacity, the call does nothing.
Why the result may be larger
reserve may request extra space to avoid frequent reallocations as the vector grows. Rust does not guarantee a particular growth strategy. That means code should not depend on a fixed multiplier or an exact capacity after a reservation. The Vec guarantees leave that strategy open while allowing callers to rely on the capacity the vector reports.
For example, Rust’s documentation starts with a vector containing one element, calls reserve(10), and checks that its capacity is at least 11. It does not assert equality. That is the useful shape of a test for your own reservation: check the promised lower bound.
What reserve_exact changes
reserve_exact avoids deliberate extra allocation for anticipated growth. Its result still has the same lower-bound guarantee. The allocator may provide more space than requested, so even this method cannot promise a precisely minimal reported capacity. Rust recommends reserve when more insertions are expected.
What to do
Use reserve(additional) when you know how many more elements you plan to add. Compare capacity() with len() + additional when checking the result. Read capacity() when you need to know the vector’s available room at that point. Choose reserve_exact only when avoiding deliberate extra reservation fits your use case, and still treat its capacity as a lower-bound result.

The Campfire
No commentsNobody has pulled up a log by this one yet. Be the first to say what you make of it.
Held for the desk. It appears after a look.