Closed
Description
Location
core::ops::ControlFlow
and all its methods. Rust docs link
Summary
The docs for core::ops::ControlFlow::is_break()
look like:
assert!(ControlFlow::<i32, String>::Break(3).is_break());
assert!(!ControlFlow::<String, i32>::Continue(3).is_break());
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 :)