mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-29 01:28:08 +08:00
16 lines
351 B
Rust
16 lines
351 B
Rust
|
extern crate trpl; // required for mdbook test
|
||
|
|
||
|
fn main() {
|
||
|
trpl::run(async {
|
||
|
// ANCHOR: channel
|
||
|
let (tx, mut rx) = trpl::channel();
|
||
|
|
||
|
let val = String::from("hi");
|
||
|
tx.send(val).unwrap();
|
||
|
|
||
|
let received = rx.recv().await.unwrap();
|
||
|
println!("Got: {received}");
|
||
|
// ANCHOR_END: channel
|
||
|
});
|
||
|
}
|