Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iterator.take_while_inclusive #389

Closed

Conversation

tranzystorekk
Copy link
Contributor

@tranzystorekk tranzystorekk commented Dec 12, 2022

Inspired by rust-itertools/itertools#616, and slightly by https://adventofcode.com/2022/day/8

Behaves almost exactly like take_while, but additionally yields the first element that failed the predicate.

The name feels clear and descriptive, but I'm not against a little bikeshedding (e.g. take_until_inclusive is also a reasonable contender, but would require inverting the predicate checks) 馃槃

@inoas
Copy link
Contributor

inoas commented Dec 13, 2022

Would this be a candidate for a flag on take_while once default args are part of the language?

@tranzystorekk
Copy link
Contributor Author

tranzystorekk commented Dec 14, 2022

Would this be a candidate for a flag on take_while once default args are part of the language?

Maybe, I don't have a strong opinion; it wouldn't seem unreasonable, but I kind of like it as a separate function

@lpil
Copy link
Member

lpil commented Dec 14, 2022

I think this is a relatively niche function and would be best kept in another package or copied into codebases

@lpil
Copy link
Member

lpil commented Dec 19, 2022

Thank you @tranzystorek-io !

@lpil lpil closed this Dec 19, 2022
@tranzystorekk tranzystorekk deleted the take-while-inclusive branch December 19, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants