Use trpl
channel in an async task
This commit is contained in:
parent
3be0c34179
commit
7ecb5e30c5
4 changed files with 2149 additions and 0 deletions
2128
async-message-passing/Cargo.lock
generated
Normal file
2128
async-message-passing/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
7
async-message-passing/Cargo.toml
Normal file
7
async-message-passing/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "async-message-passing"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
trpl = "0.2.0"
|
11
async-message-passing/src/main.rs
Normal file
11
async-message-passing/src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
fn main() {
|
||||
trpl::run(async {
|
||||
let (tx, mut rx) = trpl::channel();
|
||||
|
||||
let val = String::from("hi");
|
||||
tx.send(val).unwrap();
|
||||
|
||||
let received = rx.recv().await.unwrap();
|
||||
println!("Got: {received}");
|
||||
});
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "./async-message-passing"
|
||||
},
|
||||
{
|
||||
"path": "./async-concurrency"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue