RS.CLIPPY.USELESS_VEC
Useless `vec!`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: useless_vec. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of vec![..] when using [..] would
be possible.
Why is this bad?
This is less efficient.
Example
fn foo(_x: &[u8]) {}
foo(&vec![1, 2]);
Use instead:
foo(&[1, 2]);
Configuration
-
allow-useless-vec-in-tests: Whetheruseless_vecshould ignore test functions or#[cfg(test)](default:
false) -
too-large-for-stack: The maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap(default:
200)