Iterator icon indicating copy to clipboard operation
Iterator copied to clipboard

Import Rust iterator methods into this library

Open Hywan opened this issue 9 years ago • 0 comments

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.

Hywan avatar Dec 21 '16 14:12 Hywan