Use trpl channel in an async task

This commit is contained in:
Manuel Thalmann 2025-04-06 21:04:42 +02:00
parent 3be0c34179
commit 7ecb5e30c5
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c
4 changed files with 2149 additions and 0 deletions

2128
async-message-passing/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
[package]
name = "async-message-passing"
version = "0.1.0"
edition = "2024"
[dependencies]
trpl = "0.2.0"

View 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}");
});
}

View file

@ -1,5 +1,8 @@
{
"folders": [
{
"path": "./async-message-passing"
},
{
"path": "./async-concurrency"
},