]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | #![allow(unused_imports)] | |
3 | #![warn( | |
4 | clippy::all, | |
5 | clippy::style, | |
6 | clippy::mem_replace_option_with_none, | |
7 | clippy::mem_replace_with_default | |
8 | )] | |
9 | ||
10 | use std::mem; | |
11 | ||
12 | fn replace_option_with_none() { | |
13 | let mut an_option = Some(1); | |
14 | let _ = an_option.take(); | |
15 | let an_option = &mut Some(1); | |
16 | let _ = an_option.take(); | |
17 | } | |
18 | ||
19 | fn replace_with_default() { | |
20 | let mut s = String::from("foo"); | |
21 | let _ = std::mem::take(&mut s); | |
22 | let s = &mut String::from("foo"); | |
23 | let _ = std::mem::take(s); | |
24 | let _ = std::mem::take(s); | |
25 | } | |
26 | ||
27 | fn main() { | |
28 | replace_option_with_none(); | |
29 | replace_with_default(); | |
30 | } |