use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use enclose::enclose;
fn main() {
let mutex_data = Arc::new(Mutex::new( 0 ));
let read_data = Arc::new(1);
let thread = thread::spawn( enclose!((mutex_data, read_data) move || {
let mut lock = match mutex_data.lock() {
Ok(a) => a,
Err(e) => e.into_inner(),
};
*lock += *read_data;
}));
thread.join().unwrap();
{
let lock = match mutex_data.lock() {
Ok(a) => a,
Err(e) => e.into_inner(),
};
assert_eq!(*lock, *read_data);
}
}