]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/mem_replace_with_default.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / mem_replace_with_default.txt
1 ### What it does
2 Checks for `std::mem::replace` on a value of type
3 `T` with `T::default()`.
4
5 ### Why is this bad?
6 `std::mem` module already has the method `take` to
7 take the current value and replace it with the default value of that type.
8
9 ### Example
10 ```
11 let mut text = String::from("foo");
12 let replaced = std::mem::replace(&mut text, String::default());
13 ```
14 Is better expressed with:
15 ```
16 let mut text = String::from("foo");
17 let taken = std::mem::take(&mut text);
18 ```