pushgen
Push-style design pattern for processing of ranges and data-streams.
This is a Rust-based approach to the design pattern described by transrangers.
While the discussion linked targets C++, the same basic principle of pull-based iterators applies
to Rust as well (with some modifications since Rust doesn't have a concept of an end
iterator
like C++ does).
Example
let data = ;
for item in data.iter.filter.map
can be rewritten as
use ;
let data = ;
new.filter.map.for_each;
Performance
I make no performance-claims, however there are some benchmarked cases where the push-based approach wins over the iterator approach, but I have made no attempts to analyze this in any depth.