-
Notifications
You must be signed in to change notification settings - Fork 311
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
take_until
and map_until
#597
Comments
I would like to take this up. I needed this functionality for a project but noticed that this is neither present in the standard library nor itertools. |
Lambda now stores tokens of the params: - Beacuse we store the params as just a vec of strings, we can't store tokens inside each param. - Impl TokenHoarder and TokenGiver for Lambda, but these must only be used for tokens of the parameters, not the body - Impl constructor for Lambda since the `param_tokens` are private Better error display in lambda: - During creation, lambdas now store the tokens of the parameters - Shows nice error if wrong number of args are given to `lambda` the built-in function - Shows nice error if any of the params are not a symbol - Shows nice error if number of args and params mismatch - shows both Fix lambda return value bug: - When the body of a lambda had an error, it would return `false` instead of showing the error - This was because `take_while` would consume the `Result` which had error, discard it and stop taking. - when it was the only expr in the body, it would return an empty iterator which causes the default value in `unwrap_or` to be returned (which was `false`) - Replaced the take_while with a manual loop - returns the first error we see and does not consume further - keeps storing the last (not error) result - returns the last result or `false` is nothing is available - Note: this could have been written a little more elegantly using something like `take_until`: - rust-lang/rust#62208 - rust-itertools/itertools#597
I'm curious how y'all envision a The difference between Maybe a |
I've been thinking about it, and I think the |
A while ago there was a proposal by Jon Gjengset (
jonhoo
) to addtake_until
into Rust's standard library:rust-lang/rust#62208
While it may be not a good fit for the standard library, it might be a worthwhile addition to
itertools
.As
michaelsproul
pointed out in the discussion,The text was updated successfully, but these errors were encountered: