mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 07:30:57 +00:00
262b35ea2c
This lint checks if Option::take() is used on a temporary value (a value that is not of type &mut Option and that is not a Place expression) to suggest omitting take()
15 lines
378 B
Rust
15 lines
378 B
Rust
// run-rustfix
|
|
|
|
fn main() {
|
|
println!("Testing non erroneous option_take_on_temporary");
|
|
let mut option = Some(1);
|
|
let _ = Box::new(move || option.take().unwrap());
|
|
|
|
println!("Testing non erroneous option_take_on_temporary");
|
|
let x = Some(3);
|
|
x.as_ref();
|
|
|
|
println!("Testing erroneous option_take_on_temporary");
|
|
let x = Some(3);
|
|
x.as_ref();
|
|
}
|