rust/tests/ui/rfcs/rfc-2175-or-if-while-let/basic.rs
2023-01-11 09:32:08 +00:00

34 lines
464 B
Rust

// run-pass
#![allow(dead_code)]
enum E {
V(u8),
U(u8),
W,
}
use E::*;
fn main() {
let mut e = V(10);
if let V(x) | U(x) = e {
assert_eq!(x, 10);
}
while let V(x) | U(x) = e {
assert_eq!(x, 10);
e = W;
}
// Accept leading `|`:
let mut e = V(10);
if let | V(x) | U(x) = e {
assert_eq!(x, 10);
}
while let | V(x) | U(x) = e {
assert_eq!(x, 10);
e = W;
}
}