Skip to content

Commit 410d8ca

Browse files
authored
Merge pull request #206 from MaxGoryunov/204
204
2 parents e53cdfa + 035af06 commit 410d8ca

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,17 @@ $valid = new ValidAddingIterator(
8282

8383
## Decorating Generators
8484

85-
You can also use it with `Generators`. If the iterator is called twice, rewind exception will **not** be thrown.
86-
87-
**Attention**: it is not (currently) possible to pass callable as a parameter. You have to manually invoke `Generator` function:
85+
You can also use it with `Generators`. If the iterator is called twice, rewind exception will **not** be thrown. Just pass a function which returns a `Generator` to the constructor:
8886

8987
```PHP
90-
function numerals(): Generator {
88+
$numerals = function (): Generator {
9189
for ($i = 0; $i < 10; $i++) {
9290
yield $i;
9391
}
94-
}
92+
};
9593

96-
$numerals = new SavingIterator(
97-
numerals(),
94+
$iter = new SavingIterator(
95+
$numerals,
9896
new ArrayAddingIterator()
9997
);
10098
```

src/SavingIterator.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public function __construct(
3232
AddingIterator $target = new ArrayAddingIterator()
3333
) {
3434
$reorigin = ($origin instanceof Closure) ? $origin() : $origin;
35-
/**
36-
* @todo #194:15min README has to show that it is now possible to
37-
* directly pass Generator Closures into constructor without
38-
* having to manually call them.
39-
*/
4035
parent::__construct(
4136
/** @phpstan-ignore-next-line */
4237
new ContextVeil(

0 commit comments

Comments
 (0)