]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/sendfn-spawn-with-fn-arg.rs
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
[rust.git] / src / test / ui / threads-sendsync / sendfn-spawn-with-fn-arg.rs
1 // run-pass
2 // ignore-emscripten no threads support
3
4 use std::thread;
5
6 pub fn main() { test05(); }
7
8 fn test05_start<F:FnOnce(isize)>(f: F) {
9     f(22);
10 }
11
12 fn test05() {
13     let three: Box<_> = Box::new(3);
14     let fn_to_send = move|n:isize| {
15         println!("{}", *three + n); // will copy x into the closure
16         assert_eq!(*three, 3);
17     };
18     thread::spawn(move|| {
19         test05_start(fn_to_send);
20     }).join().ok().unwrap();
21 }