Iterator
Iterator copied to clipboard
Import Rust iterator methods into this library
For instance:
$any = (new Iterator\Map($data)).any(function ($item) { return 0 === $item % 2; })
instead of:
$any = false;
foreach ($data as $datum) {
if (0 === $item % 2) {
$any = true;
break;
}
}
The first is less error-prone, normally bug-free, and easier to read. We can optimise it a lot too.
See the Rust iterator API: https://doc.rust-lang.org/std/iter/trait.Iterator.html.
We should benchmark results with manual implementation vs. iterator_apply.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.