2020-03-05 07:36:19 -06:00
|
|
|
#![warn(clippy::if_let_mutex)]
|
|
|
|
|
|
|
|
use std::sync::Mutex;
|
|
|
|
|
2020-03-17 20:51:43 -05:00
|
|
|
fn do_stuff<T>(_: T) {}
|
2020-03-05 07:36:19 -06:00
|
|
|
|
2020-03-18 17:13:06 -05:00
|
|
|
fn if_let() {
|
|
|
|
let m = Mutex::new(1u8);
|
2020-03-17 20:51:43 -05:00
|
|
|
if let Err(locked) = m.lock() {
|
|
|
|
do_stuff(locked);
|
2020-03-05 07:36:19 -06:00
|
|
|
} else {
|
2020-03-17 20:51:43 -05:00
|
|
|
let lock = m.lock().unwrap();
|
|
|
|
do_stuff(lock);
|
2020-03-05 07:36:19 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|