Create a project for demonstrating streams

This commit is contained in:
Manuel Thalmann 2025-04-10 08:15:00 +02:00
parent c86f38aa32
commit 44a71c13e4
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c
4 changed files with 2151 additions and 0 deletions

2128
async-streams/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

7
async-streams/Cargo.toml Normal file
View file

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

13
async-streams/src/main.rs Normal file
View file

@ -0,0 +1,13 @@
use trpl::StreamExt;
fn main() {
trpl::run(async {
let values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let iter = values.iter().map(|n| n * 2);
let mut stream = trpl::stream_from_iter(iter);
while let Some(value) = stream.next().await {
println!("The value was: {value}");
}
});
}

View file

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