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
hi when i use rust 1.53 version some code about pattern match below make me confused,and i think this is a bug or a problem that cannot be ignored.
let x = Some(2);assert!(matches!(x,Some(1 | 2)));//ok x is Some(2)assert!(matches!(Some(1),Some(1|2)));//okassert!(matches!(Some(2),Some(1|2)));//oklet y = Some(1 | 2);//y is Some(3)// assert!(matches!(Some(3),Some(1|2)));// error, Some(1|2) =>is Some(1) | Some(2) or Some(3)?
Activity
bugadani commentedon Jun 17, 2021
This isn't new at all: rust-lang/rfcs#2535 (comment)
Since
1|2already had the same ambiguoity, this has been kind of "ignored" as far as I understand, but don't quote me on the reasoning.jonas-schievink commentedon Jun 17, 2021
or-patterns do not function as binary operators. This is working as intended, so closing.