Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for Iterator::try_fold and try_rfold (feature iterator_try_fold) #45594
Comments
This comment has been minimized.
This comment has been minimized.
leonardo-m
commented
Oct 28, 2017
|
Is this usable to implement a fold1? |
This comment has been minimized.
This comment has been minimized.
|
There's already a fold1 in itertools and its implementation is quite simple: fn fold1<F>(mut self, f: F) -> Option<Self::Item>
where F: FnMut(Self::Item, Self::Item) -> Self::Item,
Self: Sized,
{
self.next().map(move |x| self.fold(x, f))
}The major difference to haskell foldl1 is that itertools fold1 returns an Option, with None for when the iterator is empty, instead of a runtime error like in Haskell. |
This comment has been minimized.
This comment has been minimized.
|
That same technique is also used for the |
TimNN
added
the
C-tracking-issue
label
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
|
I think |
This comment has been minimized.
This comment has been minimized.
|
Well, |
cuviper
referenced this issue
Dec 19, 2017
Closed
Implement functionality like `Iterator::try_fold` #495
This comment has been minimized.
This comment has been minimized.
|
I wound up writing some code that really wanted |
This was referenced Feb 12, 2018
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Feb 19, 2018
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Feb 19, 2018
This comment has been minimized.
This comment has been minimized.
|
Should we try to stabilize |
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Feb 23, 2018
|
Why not try_fold into |
Manishearth
added a commit
to Manishearth/rust
that referenced
this issue
Feb 23, 2018
This comment has been minimized.
This comment has been minimized.
In a perfect world the two signatures would be equivalent, but the code that landed already uses the formulation that works better with inference so I think it’s better to keep it that way.
Let’s stabilize them all together? :) @rfcbot fcp merge As of today |
scottmcm
referenced this issue
Mar 17, 2018
Closed
Tracking issue for (DoubleEnded)?Iterator::rfind #39480
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Looks like the rfcbot command didn't take. Does it need to be the first line? |
cramertj
added
the
T-libs
label
Mar 22, 2018
This comment has been minimized.
This comment has been minimized.
|
@scottmcm The issue was missing a team tag :). @SimonSapin If you try again it should enter FCP (I cannot, as I am not on the libs team). |
This comment has been minimized.
This comment has been minimized.
|
Let’s try again: @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 22, 2018
•
|
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Mar 22, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 22, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Mar 22, 2018
This comment has been minimized.
This comment has been minimized.
|
To be clear, this is stabilizing before the This completely slipped by me even though I desperately wish for it all the time, as I never would've figured that functions involving Try would be receiving stabilization yet. I hope we've gained enough experience using these to validate their utility? Note: I know this is not unheard of; consider the |
This comment has been minimized.
This comment has been minimized.
|
Yes, this is stabilizing before the That doesn't scare me on the flexibility side because, no matter how the On the consumption side, I'm not worried because this is basically the same as itertools's They've also been discussed for a while as core internal iteration methods, though those wins are only available to stdlib types until the Now, one could argue that |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 1, 2018
|
The final comment period is now complete. |
scottmcm commentedOct 28, 2017
•
edited
The core internal iteration methods in terms of which the other
Iteratormethods can be implemented.PR #45595, commit b32267f -- merged 2017-11-17
https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.try_fold
https://doc.rust-lang.org/nightly/std/iter/trait.DoubleEndedIterator.html#method.try_rfold
Also
try_for_each(PR #48157, merged 2018-02-24), a convenience method that can be considered the fallible version offor_eachor the stateless version oftry_fold.https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.try_for_each
Pre-stabilization question list:
try_foreachas well? #45379 (comment)rfoldbeforetry_rfold? #45594 (comment)try_foldbefore the others? #45594 (comment)