]>
Commit | Line | Data |
---|---|---|
0731742a XL |
1 | // Test overloaded resolution of fn_traits. |
2 | // run-pass | |
3 | ||
4 | #![feature(fn_traits)] | |
5 | #![feature(unboxed_closures)] | |
6 | ||
7 | #[derive(Debug, PartialEq, Eq)] | |
8 | struct Ishmael; | |
9 | #[derive(Debug, PartialEq, Eq)] | |
10 | struct Maybe; | |
11 | struct CallMe; | |
12 | ||
13 | impl FnOnce<(Ishmael,)> for CallMe { | |
14 | type Output = Ishmael; | |
15 | extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> Ishmael { | |
16 | println!("Split your lungs with blood and thunder!"); | |
17 | Ishmael | |
18 | } | |
19 | } | |
20 | ||
21 | impl FnOnce<(Maybe,)> for CallMe { | |
22 | type Output = Maybe; | |
23 | extern "rust-call" fn call_once(self, _args: (Maybe,)) -> Maybe { | |
24 | println!("So we just met, and this is crazy"); | |
25 | Maybe | |
26 | } | |
27 | } | |
28 | ||
29 | fn main() { | |
30 | assert_eq!(CallMe(Ishmael), Ishmael); | |
31 | assert_eq!(CallMe(Maybe), Maybe); | |
32 | } |