enclose 0.1.3

A convenient macro for cloning values into a closure.
Documentation


use std::sync::Arc;
use std::sync::Mutex;
use std::thread;

use enclose::enc;
use enclose::enclose;


fn main() {
     let v = Arc::new(Mutex::new( 0 ));
	let thread = thread::spawn( enc!((v) move || {
		let mut v_lock = match v.lock() {
			Ok(a) => a,
			Err(e) => e.into_inner(),
		};
		*v_lock += 1;
	}));

	thread.join().unwrap();
	{
		let v_lock = match v.lock() {
			Ok(a) => a,
			Err(e) => e.into_inner(),
		};
		assert_eq!(*v_lock, 1);
	}
}