]> git.lizzy.rs Git - rust.git/blob - src/docs/box_collection.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / box_collection.txt
1 ### What it does
2 Checks for use of `Box<T>` where T is a collection such as Vec anywhere in the code.
3 Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information.
4
5 ### Why is this bad?
6 Collections already keeps their contents in a separate area on
7 the heap. So if you `Box` them, you just add another level of indirection
8 without any benefit whatsoever.
9
10 ### Example
11 ```
12 struct X {
13     values: Box<Vec<Foo>>,
14 }
15 ```
16
17 Better:
18
19 ```
20 struct X {
21     values: Vec<Foo>,
22 }
23 ```