Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Rename and expose LoopState as ControlFlow #76204
Rename and expose LoopState as ControlFlow #76204
Changes from 1 commit
d0af125
96eb5e1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash
and especiallyEq
seem handy, although they are not needed to replaceLoopState
and are less essential forControlFlow
than forOption
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that seems sensible! I don't know when you'd want to hash this but I suppose there's no reason to prevent it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found that
C = ()
is very common when using this enum, common enough that it might deserve a defaulted type parameter. We could add one backwards compatibly but only ifC
followsB
in the parameter list. Otherwise we would have to defaultB
at the same time and anyone that wishes to override it would have to overrideC
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! It's even usually that way in the uses this PR touches, like

I suppose we could even do
ControlFlow<B = (), C = ()>
the same waybreak;
isbreak ();
.(Though I suppose the reorder might make the diff messier, so could also be a separate PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be confusing to do this without changing the order of the variants as well, and we may as well do that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On consideration, I think a separate PR would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the second parameter be
R::Error
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, definitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see - we can't do this because it's an unconstrained type parameter. Is there a good way to solve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the break part here is intentionally the full
impl Try
type (Result
, etc). They're definitely strange APIs, though --break_value
is something that could plausibly stabilize, but these ones probably aren't.Maybe leave this particular impl block over in
iter
as non-pub so they can still be used there, but don't show up in the rustdoc? (And won't need#[unstable]
since they'll be unusable outsideiter
.)I've been contemplating making a pass through the implementations to use
feature(try_blocks)
instead of explicitTry::foo
calls where possible; this PR going in would be a good impetus to go do that -- and hopefully delete these methods while I'm at it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I misunderstood how these were being used. You're right, it's a very strange API.