2019-11-04 00:00:00 +00:00
|
|
|
//@ check-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2015-12-02 17:31:49 -08:00
|
|
|
#![feature(fn_traits, unboxed_closures)]
|
2014-06-17 14:14:06 -04:00
|
|
|
|
|
|
|
use std::ops::Fn;
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
trait Response { fn dummy(&self) { } }
|
|
|
|
trait Request { fn dummy(&self) { } }
|
2014-06-17 14:14:06 -04:00
|
|
|
trait Ingot<R, S> {
|
|
|
|
fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
struct HelloWorld;
|
|
|
|
|
2015-02-12 10:29:52 -05:00
|
|
|
struct SendFile;
|
2014-06-17 14:14:06 -04:00
|
|
|
struct Alloy;
|
|
|
|
enum Status {
|
|
|
|
Continue
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Alloy {
|
|
|
|
fn find<T>(&self) -> Option<T> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
impl<'b> Fn<(&'b mut (dyn Response + 'b),)> for SendFile {
|
|
|
|
extern "rust-call" fn call(&self, (_res,): (&'b mut (dyn Response + 'b),)) {}
|
2015-03-11 10:08:33 -04:00
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
impl<'b> FnMut<(&'b mut (dyn Response + 'b),)> for SendFile {
|
|
|
|
extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (dyn Response+'b),)) {
|
2015-03-11 10:08:33 -04:00
|
|
|
self.call((_res,))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
impl<'b> FnOnce<(&'b mut (dyn Response + 'b),)> for SendFile {
|
2015-01-12 10:27:25 -05:00
|
|
|
type Output = ();
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
extern "rust-call" fn call_once(self, (_res,): (&'b mut (dyn Response+'b),)) {
|
2015-03-11 10:08:33 -04:00
|
|
|
self.call((_res,))
|
|
|
|
}
|
2014-06-17 14:14:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld {
|
|
|
|
fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status {
|
|
|
|
let send_file = alloy.find::<SendFile>().unwrap();
|
|
|
|
send_file(res);
|
2014-11-06 00:05:53 -08:00
|
|
|
Status::Continue
|
2014-06-17 14:14:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|