mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
351 B
16 lines
351 B
4 months ago
|
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
|
||
|
});
|
||
|
}
|