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