Testing a thread that invoke an FnMut callback

Hello,

I am doing an async implementation of an iterator as follow:

pub fn iter_mut<T, F>(input: Vec<T>, callback : F) 
    where
        T: 'static + PartialOrd + Ord + Clone + Send,
        F: 'static + Box<FnMut(Vec<T>) + Send>,
    {
        let computer_handler = thread::spawn(move || {
            let iterator = PermutationIterator::new(input);

            for permutation in iterator {
                callback(permutation)
            }
        });

        computer_handler.join();

    }

And the test is:

#[test]
fn should_invoke_a_mutable_callback() {
    let input = vec![1, 2, 3];
    let mut counter = 0;
    let receiver = |permutation| {
        counter = counter + 1;
    };
    // call
    PermutationIteratorThread::iter_mut( input, receiver );
    thread::sleep(Duration::from_secs(10));
    // assertions
    assert_eq!( 6, counter );

}

But it does not work at all.. i don't manage to do that. I won't give you the errors I have with cargo test because I have done many tries that don't succeed.

Please advise

You can have a look at the whole project here

At a glance receiver is neither 'static or Send. Make the counter an Arc<Atomic and the closure moves a clone of it.