]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/task-spawn-move-and-copy.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / threads-sendsync / task-spawn-move-and-copy.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 // ignore-emscripten no threads support
4
5 use std::thread;
6 use std::sync::mpsc::channel;
7
8 pub fn main() {
9     let (tx, rx) = channel::<usize>();
10
11     let x: Box<isize> = Box::new(1);
12     let x_in_parent = &(*x) as *const isize as usize;
13
14     let t = thread::spawn(move || {
15         let x_in_child = &(*x) as *const isize as usize;
16         tx.send(x_in_child).unwrap();
17     });
18
19     let x_in_child = rx.recv().unwrap();
20     assert_eq!(x_in_parent, x_in_child);
21
22     t.join();
23 }