-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
808b211
to
95d8b51
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 |
☔ The latest upstream changes (presumably #138087) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors r+ |
implement continue_ok and break_ok for ControlFlow Tracking issue: rust-lang#140266 r? `@dtolnay`
Rollup of 9 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #144650 (Additional tce tests) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 9 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #144650 (Additional tce tests) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) r? `@ghost` `@rustbot` modify labels: rollup
implement continue_ok and break_ok for ControlFlow Tracking issue: rust-lang#140266 r? ``@dtolnay``
implement continue_ok and break_ok for ControlFlow Tracking issue: rust-lang#140266 r? ```@dtolnay```
Rollup of 9 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143764 (lower pattern bindings in the order they're written and base drop order on primary bindings' order) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) - #144836 (Change visibility of Args new function) r? `@ghost` `@rustbot` modify labels: rollup
implement continue_ok and break_ok for ControlFlow Tracking issue: rust-lang#140266 r? ````@dtolnay````
Rollup of 21 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143679 (Preserve the .debug_gdb_scripts section) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps) - #144133 (Stabilize const TypeId::of) - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny) - #144473 (Address libunwind.a inconsistency issues in the bootstrap program) - #144498 (Add --print target-spec-json-schema) - #144552 (Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #144659 (bootstrap: refactor mingw dist and fix gnullvm) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) - #144836 (Change visibility of Args new function) - #144861 (Stabilize `panic_payload_as_str` feature) - #144910 (Add regression tests for seemingly fixed issues) - #144913 ([rustdoc] Fix wrong `i` tooltip icon) - #144917 (Enforce tail call type is related to body return type in borrowck) - #144924 (compiletest: add hint for when a ui test produces no errors) r? `@ghost` `@rustbot` modify labels: rollup
Tracking issue: #140266
r? @dtolnay