You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
snprajwal opened this issue
Dec 6, 2024
· 1 comment
· Fixed by #134032
Labels
A-docsArea: documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.
Firstly, the types switch across the two examples, which is unintuitive. The reader needs to spare the brain cells to identify which type represents Continue and Break in each case (even though the variant being used is different), which could also distract them from noticing the ! in the second statement. This would be much clearer if it looks like:
assert!(ControlFlow::<String,i32>::Break("stop right there!").is_break());assert!(!ControlFlow::<String,i32>::Continue(42).is_break());
The main change being that the types are consistent across the examples.
The same change would look good for the other methods on this enum.
I'm happy to submit a PR if someone greenlights this :)
The text was updated successfully, but these errors were encountered:
snprajwal
added
the
A-docs
Area: documentation for any part of the project, including the compiler, standard library, and tools
label
Dec 6, 2024
jieyouxu
added
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
and removed
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
labels
Dec 6, 2024
Rollup merge of rust-lang#134032 - snprajwal:fix-docs, r=joboet
docs: better examples for `std::ops::ControlFlow`
Fixesrust-lang#133963. Lesson learnt, never force-push from a bare clone of a repo 💀
A-docsArea: documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.
Location
core::ops::ControlFlow
and all its methods. Rust docs linkSummary
The docs for
core::ops::ControlFlow::is_break()
look like:Firstly, the types switch across the two examples, which is unintuitive. The reader needs to spare the brain cells to identify which type represents
Continue
andBreak
in each case (even though the variant being used is different), which could also distract them from noticing the!
in the second statement. This would be much clearer if it looks like:The main change being that the types are consistent across the examples.
The same change would look good for the other methods on this enum.
I'm happy to submit a PR if someone greenlights this :)
The text was updated successfully, but these errors were encountered: