-
Notifications
You must be signed in to change notification settings - Fork 13.3k
implement continue_ok and break_ok for ControlFlow #140267
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
base: master
Are you sure you want to change the base?
Conversation
33c5e70
to
808b211
Compare
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.
Thank you!
It would help people understand when they would benefit from these methods if the example code in the documentation showed a little bit more fleshed out skeleton of a real-world use case where using the new helpers is a nontrivial improvement.
The current example code is not useful for this purpose because it bears no resemblance to anything we would expect a user to write. In fact, even for the thing it is intended to show (that break_ok
maps Break
to Ok
) I think it is not even the best way to show that. It could instead just say something like "control_flow.break_ok()
is equivalent to: match control_flow { ...
". But this is redundant with someone clicking the "Source" link if they are still confused after reading the 1-sentence method description and the updated example, so please decide if it's worth having after updating the example.
…for break_ok/continue_ok
Thanks for the feedback! I attempted to add some more fleshed out examples for both methods. Please have a look. I think my example for I tried to find a sensible analogous usecase for Therefore, a proper good usage example for Finally, something I noticed: My examples all derive from the existing
So I was wondering, should we maybe add the explicit lifetimes in the module wide example as well, if that seems to be necessary to be able to use the method for certain usecases? @rustbot label -S-waiting-on-author +S-waiting-on-review |
Tracking issue: #140266
r? @dtolnay