]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/expr-match-struct.rs
rollup merge of #19585: mdinger/guide_typo
[rust.git] / src / test / run-pass / expr-match-struct.rs
index 93f0575b5a089e4fe374da57a0cd3fdf277a6857..83101a3d2cc3a2130e3e5364aaeb1fc59d9858dc 100644 (file)
 // Tests for match as expressions resulting in struct types
 struct R { i: int }
 
+impl Copy for R {}
+
 fn test_rec() {
-    let rs = match true { true => R {i: 100}, _ => fail!() };
+    let rs = match true { true => R {i: 100}, _ => panic!() };
     assert_eq!(rs.i, 100);
 }
 
 #[deriving(Show)]
 enum mood { happy, sad, }
 
-impl Eq for mood {
+impl Copy for mood {}
+
+impl PartialEq for mood {
     fn eq(&self, other: &mood) -> bool {
         ((*self) as uint) == ((*other) as uint)
     }
@@ -31,8 +35,8 @@ fn ne(&self, other: &mood) -> bool { !(*self).eq(other) }
 }
 
 fn test_tag() {
-    let rs = match true { true => { happy } false => { sad } };
-    assert_eq!(rs, happy);
+    let rs = match true { true => { mood::happy } false => { mood::sad } };
+    assert_eq!(rs, mood::happy);
 }
 
 pub fn main() { test_rec(); test_tag(); }