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