rust/tests/ui/or-patterns/for-loop.rs
2023-01-11 09:32:08 +00:00

17 lines
361 B
Rust

// Check that or patterns are lowered correctly in `for` loops.
// run-pass
fn main() {
let v = vec![Ok(2), Err(3), Ok(5)];
let mut w = Vec::new();
for &(Ok(i) | Err(i)) in &v {
w.push(i);
}
let mut u = Vec::new();
for Ok(i) | Err(i) in v {
u.push(i);
}
assert_eq!(w, [2, 3, 5]);
assert_eq!(u, [2, 3, 5]);
}