2018-11-04 04:27:09 -06:00
|
|
|
// Test overloaded resolution of fn_traits.
|
2018-11-08 03:39:46 -06:00
|
|
|
//@ run-pass
|
2018-11-04 04:27:09 -06:00
|
|
|
|
|
|
|
#![feature(fn_traits)]
|
|
|
|
#![feature(unboxed_closures)]
|
|
|
|
|
2018-11-27 08:15:27 -06:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2018-11-04 04:27:09 -06:00
|
|
|
struct Ishmael;
|
2018-11-27 08:15:27 -06:00
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
2018-11-04 04:27:09 -06:00
|
|
|
struct Maybe;
|
|
|
|
struct CallMe;
|
|
|
|
|
|
|
|
impl FnOnce<(Ishmael,)> for CallMe {
|
2018-11-27 08:15:27 -06:00
|
|
|
type Output = Ishmael;
|
|
|
|
extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> Ishmael {
|
2018-11-04 04:27:09 -06:00
|
|
|
println!("Split your lungs with blood and thunder!");
|
2018-11-27 08:15:27 -06:00
|
|
|
Ishmael
|
2018-11-04 04:27:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FnOnce<(Maybe,)> for CallMe {
|
2018-11-27 08:15:27 -06:00
|
|
|
type Output = Maybe;
|
|
|
|
extern "rust-call" fn call_once(self, _args: (Maybe,)) -> Maybe {
|
2018-11-04 04:27:09 -06:00
|
|
|
println!("So we just met, and this is crazy");
|
2018-11-27 08:15:27 -06:00
|
|
|
Maybe
|
2018-11-04 04:27:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-11-27 08:15:27 -06:00
|
|
|
assert_eq!(CallMe(Ishmael), Ishmael);
|
|
|
|
assert_eq!(CallMe(Maybe), Maybe);
|
2018-11-04 04:27:09 -06:00
|
|
|
}
|