-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for iterator_fold_self #68125
Comments
For me as a Haskeller who relatively new to Rust, |
Following Scala's approach, what about |
Kotlin is doing the same naming. https://kotlinlang.org/docs/reference/collection-aggregate.html#fold-and-reduce |
I prefer
but |
|
Why only |
I think |
This functionality is very useful for situations where there's no reasonable default value. For example, I'm using it for a parser, and would be very interested in it being stabilized. I don't have a strong opinion on the name. |
I concur, this would be very useful regardless of the name. |
I'd like to officially push for stabilization. This feature is useful and available in many other languages, and the implementation is simple and non-controversial. The only debate so far is the name. I'll list the primary contenders for the name and the pros/cons I've read for each:
|
Personally, I'm against
I'm also slightly in favour of |
Perhaps, something like |
I found myself wanting this last night. Based on the context in which I was using it, any of |
Edited the summary post based on the comments above. I've removed To move things towards completion, I am now disprefering |
Another argument against |
I personally prefer the name I don't think discoverability is a problem, as the documentation for And as already mentioned above, we already have |
I agree that the |
@WaffleLapkin I've already nominated this issue for the next libs meeting to make a decision on this. But looking at the 15 👍 and 0 👎 (currently at least) on the |
I have no experience with Kotlin or Scala, but coming from JavaScript, the name I've just used |
Ditto for Python, where it's called |
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Responding to this comment:
Another solution to this would be to use I also stumbled onto this issue due to Advent of Code, and I'm a firm proponent of |
This comment has been minimized.
This comment has been minimized.
Welcome to Rust! :)
It'd be better to ask quesitons like that on Discord or the users forum, to keep (tracking) issues like this focussed on the design of the API. Thanks! |
@imjasonmiller #79805 (comment) brings up another concern for
|
@rossmacarthur there's some more great discussion in that issue as well. It definitely flipped my opinion. While |
Yeah, it's also my concern that |
FWIW, and this may be a minor point, but I like the fact that If this were |
Regardless of the name, this would be extremely useful. I myself am partial to |
I prefer |
@arnabanimesh See the stabilization PR for that discussion. |
Rename Iterator::fold_first to reduce and stabilize it This stabilizes `#![feature(iterator_fold_self)]`. The name for this function (originally `fold_first`) was still an open question, but the discussion on [the tracking issue](rust-lang#68125) seems to have converged to `reduce`.
Rename Iterator::fold_first to reduce and stabilize it This stabilizes `#![feature(iterator_fold_self)]`. The name for this function (originally `fold_first`) was still an open question, but the discussion on [the tracking issue](rust-lang#68125) seems to have converged to `reduce`.
Rename Iterator::fold_first to reduce and stabilize it This stabilizes `#![feature(iterator_fold_self)]`. The name for this function (originally `fold_first`) was still an open question, but the discussion on [the tracking issue](rust-lang#68125) seems to have converged to `reduce`.
Stabilized in #79805, this issue can be closed 🙂 |
Tracking issue for
Iterator::fold_first
, likefold1
in Haskell.Steps
fold_self
andtry_fold_self
for Iterators #65222Open questions
fold_first
fold_with_first
fold1
reduce
Should we reconsidertry_fold_first
?The text was updated successfully, but these errors were encountered: