1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
16 fn fun1(e1: &Enum, e2: &Enum) -> uint {
18 (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0,
19 (&Enum::Foo { foo: _ }, &Enum::Bar { bar: _ }) => 1,
20 (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2,
21 (&Enum::Bar { bar: _ }, &Enum::Foo { foo: _ }) => 3,
25 fn fun2(e1: &Enum, e2: &Enum) -> uint {
27 (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0,
28 (&Enum::Foo { foo: _ }, _ ) => 1,
29 (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2,
30 (&Enum::Bar { bar: _ }, _ ) => 3,
35 let foo = Enum::Foo { foo: 1 };
36 let bar = Enum::Bar { bar: 1 };
38 assert_eq!(fun1(&foo, &foo), 0);
39 assert_eq!(fun1(&foo, &bar), 1);
40 assert_eq!(fun1(&bar, &bar), 2);
41 assert_eq!(fun1(&bar, &foo), 3);
43 assert_eq!(fun2(&foo, &foo), 0);
44 assert_eq!(fun2(&foo, &bar), 1); // fun2 returns 0
45 assert_eq!(fun2(&bar, &bar), 2);
46 assert_eq!(fun2(&bar, &foo), 3); // fun2 returns 2