rust-clippy/tests/ui/needless_option_take.rs
infrandomness 2903b56f17 Add tests and docs
This adds test to make sure correct behavior of lint
- The first test's option variable is not a temporary variable
- The second test does not make usage of `take()`
- The third test makes usage of `take()` and uses a temporary variable
2022-04-14 13:16:46 +02:00

15 lines
385 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().take();
}