Iterator Pipeline Lazy Evaluation
Chain iterator adapters for lazy evaluation in Rust data processing pipelines.
Code
fn process(data: Vec<i32>) -> Vec<i32> {
data.into_iter()
.filter(|&x| x > 0)
.map(|x| x * 2)
.take(100)
.collect()
}
fn main() {
let data: Vec<i32> = (1..=1000).collect();
let result = process(data);
println!("{:?}", result);
}Report a problem with this exampleOpens a pre-filled issue on GitHub.