summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/box_default.txt
blob: 1c670c7733377f04f3dcaefdd4158b7ff59332f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### What it does
checks for `Box::new(T::default())`, which is better written as
`Box::<T>::default()`.

### Why is this bad?
First, it's more complex, involving two calls instead of one.
Second, `Box::default()` can be faster
[in certain cases](https://nnethercote.github.io/perf-book/standard-library-types.html#box).

### Example
```
let x: Box<String> = Box::new(Default::default());
```
Use instead:
```
let x: Box<String> = Box::default();
```