blob: 775243b9c620bc1265d173e224242424b2644fec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Test that `#[loop_match]` supports or-patterns.
//@ run-pass
#![allow(incomplete_features)]
#![feature(loop_match)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum State {
A,
B,
C,
D,
}
fn main() {
let mut states = vec![];
let mut first = true;
let mut state = State::A;
#[loop_match]
'a: loop {
state = 'blk: {
match state {
State::A => {
states.push(state);
if first {
#[const_continue]
break 'blk State::B;
} else {
#[const_continue]
break 'blk State::D;
}
}
State::B | State::D => {
states.push(state);
if first {
first = false;
#[const_continue]
break 'blk State::A;
} else {
#[const_continue]
break 'blk State::C;
}
}
State::C => {
states.push(state);
break 'a;
}
}
}
}
assert_eq!(states, [State::A, State::B, State::A, State::D, State::C]);
}
|