mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
17 lines
312 B
Rust
17 lines
312 B
Rust
//@ run-pass
|
|
//@ needs-threads
|
|
|
|
use std::sync::mpsc::channel;
|
|
use std::thread;
|
|
|
|
pub fn main() {
|
|
let (tx, rx) = channel::<&'static str>();
|
|
|
|
let t = thread::spawn(move || {
|
|
assert_eq!(rx.recv().unwrap(), "hello, world");
|
|
});
|
|
|
|
tx.send("hello, world").unwrap();
|
|
t.join().ok().unwrap();
|
|
}
|