mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-05-03 03:50:29 +08:00
16 lines
306 B
Rust
Executable File
16 lines
306 B
Rust
Executable File
use std::sync::mpsc;
|
|
use std::thread;
|
|
|
|
fn main() {
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
thread::spawn(move || {
|
|
let val = String::from("hi");
|
|
tx.send(val).unwrap();
|
|
println!("val is {}", val);
|
|
});
|
|
|
|
let received = rx.recv().unwrap();
|
|
println!("Got: {}", received);
|
|
}
|