RS.CLIPPY.BOX_COLLECTION
Usage of `Box<Vec<T>>`, vector elements are already on the heap
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: box_collection. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of Box<T> where T is a collection such as Vec anywhere in the code.
Check the Box documentation for more information.
Why is this bad?
Collections already keeps their contents in a separate area on
the heap. So if you Box them, you just add another level of indirection
without any benefit whatsoever.
Example
struct X {
values: Box<Vec<Foo>>,
}
Better:
struct X {
values: Vec<Foo>,
}
Past names
- box_vec
Configuration
-
avoid-breaking-exported-api: Suppress lints whenever the suggested change would cause breakage for other crates.(default:
true)