]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/record-pat.rs
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
[rust.git] / src / test / ui / structs-enums / record-pat.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3 #![allow(non_shorthand_field_patterns)]
4
5 enum t1 { a(isize), b(usize), }
6 struct T2 {x: t1, y: isize}
7 enum t3 { c(T2, usize), }
8
9 fn m(input: t3) -> isize {
10     match input {
11       t3::c(T2 {x: t1::a(m), ..}, _) => { return m; }
12       t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as isize) + y; }
13     }
14 }
15
16 pub fn main() {
17     assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4)), 10);
18     assert_eq!(m(t3::c(T2 {x: t1::b(10), y: 5}, 4)), 19);
19 }