]> git.lizzy.rs Git - rust.git/blob - src/docs/vec_box.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / vec_box.txt
1 ### What it does
2 Checks for use of `Vec<Box<T>>` where T: Sized 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 `Vec` already keeps its contents in a separate area on
7 the heap. So if you `Box` its contents, you just add another level of indirection.
8
9 ### Known problems
10 Vec<Box<T: Sized>> makes sense if T is a large type (see [#3530](https://github.com/rust-lang/rust-clippy/issues/3530),
11 1st comment).
12
13 ### Example
14 ```
15 struct X {
16     values: Vec<Box<i32>>,
17 }
18 ```
19
20 Better:
21
22 ```
23 struct X {
24     values: Vec<i32>,
25 }
26 ```