]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/mem_replace.fixed
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / mem_replace.fixed
CommitLineData
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
10use std::mem;
11
12fn 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
19fn 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
27fn main() {
28 replace_option_with_none();
29 replace_with_default();
30}