rust-clippy/tests/ui/if_let_mutex.rs

18 lines
280 B
Rust
Raw Normal View History

#![warn(clippy::if_let_mutex)]
use std::sync::Mutex;
2020-03-18 01:51:43 +00:00
fn do_stuff<T>(_: T) {}
fn foo() {
let m = Mutex::new(1u8);
2020-03-18 01:51:43 +00:00
if let Err(locked) = m.lock() {
do_stuff(locked);
} else {
2020-03-18 01:51:43 +00:00
let lock = m.lock().unwrap();
do_stuff(lock);
};
}
fn main() {}