summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/mem_replace_option_with_none.txt
blob: 7f243d1c165658739add51f38587759f1287955e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### What it does
Checks for `mem::replace()` on an `Option` with
`None`.

### Why is this bad?
`Option` already has the method `take()` for
taking its current value (Some(..) or None) and replacing it with
`None`.

### Example
```
use std::mem;

let mut an_option = Some(0);
let replaced = mem::replace(&mut an_option, None);
```
Is better expressed with:
```
let mut an_option = Some(0);
let taken = an_option.take();
```