]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/box_default.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / box_default.txt
1 ### What it does
2 checks for `Box::new(T::default())`, which is better written as
3 `Box::<T>::default()`.
4
5 ### Why is this bad?
6 First, it's more complex, involving two calls instead of one.
7 Second, `Box::default()` can be faster
8 [in certain cases](https://nnethercote.github.io/perf-book/standard-library-types.html#box).
9
10 ### Example
11 ```
12 let x: Box<String> = Box::new(Default::default());
13 ```
14 Use instead:
15 ```
16 let x: Box<String> = Box::default();
17 ```