Create a project for demonstrating streams
This commit is contained in:
parent
c86f38aa32
commit
44a71c13e4
4 changed files with 2151 additions and 0 deletions
2128
async-streams/Cargo.lock
generated
Normal file
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
7
async-streams/Cargo.toml
Normal 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
13
async-streams/src/main.rs
Normal 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}");
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "./async-streams"
|
||||
},
|
||||
{
|
||||
"path": "./async-message-passing"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue