2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2017-06-25 02:29:10 +00:00
|
|
|
pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; }
|
2014-01-29 22:39:09 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
impl<F> OpInt for F where F: FnMut(isize, isize) -> isize {
|
|
|
|
fn call(&mut self, a:isize, b:isize) -> isize {
|
2014-01-29 22:39:09 +00:00
|
|
|
(*self)(a, b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 18:47:21 +00:00
|
|
|
fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) }
|
2014-01-29 22:39:09 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn muli(x:isize, y:isize) -> isize { x * y }
|
2014-01-29 22:39:09 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2015-02-01 17:44:15 +00:00
|
|
|
let mut f = |x, y| muli(x, y);
|
2014-01-29 22:39:09 +00:00
|
|
|
{
|
2014-04-22 06:25:18 +00:00
|
|
|
let g = &mut f;
|
2019-05-28 18:47:21 +00:00
|
|
|
let h = g as &mut dyn OpInt;
|
2014-01-29 22:39:09 +00:00
|
|
|
squarei(3, h);
|
|
|
|
}
|
|
|
|
}
|