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.
21 lines
482 B
21 lines
482 B
extern crate trpl; // required for mdbook test
|
|
|
|
// ANCHOR: all
|
|
use trpl::StreamExt;
|
|
|
|
fn main() {
|
|
trpl::run(async {
|
|
let values = 1..101;
|
|
let iter = values.map(|n| n * 2);
|
|
let stream = trpl::stream_from_iter(iter);
|
|
|
|
let mut filtered =
|
|
stream.filter(|value| value % 3 == 0 || value % 5 == 0);
|
|
|
|
while let Some(value) = filtered.next().await {
|
|
println!("The value was: {value}");
|
|
}
|
|
});
|
|
}
|
|
// ANCHOR_END: all
|