18 lines
No EOL
469 B
Text
18 lines
No EOL
469 B
Text
### 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);
|
|
``` |