blob: b7a44ed86239584cca3d8013e72b8024c67a07c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// run-pass
// pretty-expanded FIXME #23616
pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; }
impl<F> OpInt for F where F: FnMut(isize, isize) -> isize {
fn call(&mut self, a:isize, b:isize) -> isize {
(*self)(a, b)
}
}
fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) }
fn muli(x:isize, y:isize) -> isize { x * y }
pub fn main() {
let mut f = |x, y| muli(x, y);
{
let g = &mut f;
let h = g as &mut dyn OpInt;
squarei(3, h);
}
}
|