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
When we call or(false, true), it matches the (b, _) pattern, then runs the guard which fails, then matches the (_, b) pattern in the same arm and runs the guard again which succeeds, and then finally returns true.
With the current documentation (book, refererence), it's not clear that after matching (b, _) and failing the guard, it will try to match the (_, b) pattern in the same arm instead of failing the whole arm proceeding to the next arm (_ => false).
Example function (playground):
When we call
or(false, true)
, it matches the(b, _)
pattern, then runs the guard which fails, then matches the(_, b)
pattern in the same arm and runs the guard again which succeeds, and then finally returnstrue
.With the current documentation (book, refererence), it's not clear that after matching
(b, _)
and failing the guard, it will try to match the(_, b)
pattern in the same arm instead of failing the whole arm proceeding to the next arm (_ => false
).See also rust-lang/rust#26998, rust-lang/rust#26012.
(moved from rust-lang/rust#51745)
The text was updated successfully, but these errors were encountered: