]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/or-patterns/search-via-bindings.rs
1 // Check that we expand multiple or-patterns from left to right.
5 fn search(target
: (bool
, bool
, bool
)) -> u32 {
6 let x
= ((false, true), (false, true), (false, true));
7 let mut guard_count
= 0;
9 ((a
, _
) | (_
, a
), (b @ _
, _
) | (_
, b @ _
), (c @
false, _
) | (_
, c @
true))
21 // Equivalent to the above code, but hopefully easier to understand.
22 fn search_old_style(target
: (bool
, bool
, bool
)) -> u32 {
23 let x
= ((false, true), (false, true), (false, true));
24 let mut guard_count
= 0;
26 ((a
, _
), (b @ _
, _
), (c @
false, _
))
27 | ((a
, _
), (b @ _
, _
), (_
, c @
true))
28 | ((a
, _
), (_
, b @ _
), (c @
false, _
))
29 | ((a
, _
), (_
, b @ _
), (_
, c @
true))
30 | ((_
, a
), (b @ _
, _
), (c @
false, _
))
31 | ((_
, a
), (b @ _
, _
), (_
, c @
true))
32 | ((_
, a
), (_
, b @ _
), (c @
false, _
))
33 | ((_
, a
), (_
, b @ _
), (_
, c @
true))
46 assert_eq
!(search((false, false, false)), 1);
47 assert_eq
!(search((false, false, true)), 2);
48 assert_eq
!(search((false, true, false)), 3);
49 assert_eq
!(search((false, true, true)), 4);
50 assert_eq
!(search((true, false, false)), 5);
51 assert_eq
!(search((true, false, true)), 6);
52 assert_eq
!(search((true, true, false)), 7);
53 assert_eq
!(search((true, true, true)), 8);
55 assert_eq
!(search_old_style((false, false, false)), 1);
56 assert_eq
!(search_old_style((false, false, true)), 2);
57 assert_eq
!(search_old_style((false, true, false)), 3);
58 assert_eq
!(search_old_style((false, true, true)), 4);
59 assert_eq
!(search_old_style((true, false, false)), 5);
60 assert_eq
!(search_old_style((true, false, true)), 6);
61 assert_eq
!(search_old_style((true, true, false)), 7);
62 assert_eq
!(search_old_style((true, true, true)), 8);