Skip to content

Comments

Add a changelog entry for each's early stopping#6668

Merged
dlang-bot merged 1 commit intodlang:masterfrom
wilzbach:changelog-early
Aug 19, 2018
Merged

Add a changelog entry for each's early stopping#6668
dlang-bot merged 1 commit intodlang:masterfrom
wilzbach:changelog-early

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Aug 15, 2018

See also: #5268

Preview:

image

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#6668"


$(REF each, std,algorithm,iteration) is now capable of exiting early.
When a `No.each` $(REF Flag, std,typecons) is passed to `each`, the iteration will be aborted early.
For example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor) I had to read this a couple times to get it. Perhaps better would be if the wording describes what the iteration function returns rather than what is passed to each. A slightly different example showing both yes and no cases might also do this. eg.

auto arr = [10, 20, 30];
arr.each!((n) { arr ~= n; return (n == 20) ? No.each : Yes.each; });
assert(arr == [10, 20, 30, 10, 20]);

Copy link
Contributor Author

@wilzbach wilzbach Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I tried to rephrase it and used your proposed example. Thanks!

@jondegenhardt
Copy link
Contributor

LGTM

@dlang-bot dlang-bot merged commit daeea66 into dlang:master Aug 19, 2018
@wilzbach wilzbach deleted the changelog-early branch August 21, 2018 15:43
@wilzbach
Copy link
Contributor Author

Ah damn. It looks like this was merged shortly after the 2.082 branch-off has happened.
Thus, I cherry-picked it for stable: #6676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants