summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/mem_replace_with_default.txt
blob: 24e0913a30c920319bdfbc33b64c3beaf7f551f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### What it does
Checks for `std::mem::replace` on a value of type
`T` with `T::default()`.

### Why is this bad?
`std::mem` module already has the method `take` to
take the current value and replace it with the default value of that type.

### Example
```
let mut text = String::from("foo");
let replaced = std::mem::replace(&mut text, String::default());
```
Is better expressed with:
```
let mut text = String::from("foo");
let taken = std::mem::take(&mut text);
```