RS.CLIPPY.RESERVE_AFTER_INITIALIZATION

`reserve` called immediately after `Vec` creation

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: reserve_after_initialization. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Informs the user about a more concise way to create a vector with a known capacity.

Why is this bad?

The Vec::with_capacity constructor is less complex.

Example

let mut v: Vec<usize> = vec![];
v.reserve(10);

Use instead:

let mut v: Vec<usize> = Vec::with_capacity(10);