]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/expr-match-struct.rs
Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
[rust.git] / src / test / ui / structs-enums / expr-match-struct.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3
4
5
6
7 // Tests for match as expressions resulting in struct types
8 #[derive(Copy, Clone)]
9 struct R { i: isize }
10
11 fn test_rec() {
12     let rs = match true { true => R {i: 100}, _ => panic!() };
13     assert_eq!(rs.i, 100);
14 }
15
16 #[derive(Copy, Clone, Debug)]
17 enum mood { happy, sad, }
18
19 impl PartialEq for mood {
20     fn eq(&self, other: &mood) -> bool {
21         ((*self) as usize) == ((*other) as usize)
22     }
23     fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
24 }
25
26 fn test_tag() {
27     let rs = match true { true => { mood::happy } false => { mood::sad } };
28     assert_eq!(rs, mood::happy);
29 }
30
31 pub fn main() { test_rec(); test_tag(); }