blob: f77733d106d4f4d6f0e1603140dcb45659f75431 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
// run-pass
use std::ops::FnMut;
fn make_adder(x: isize) -> Box<dyn FnMut(isize)->isize + 'static> {
Box::new(move |y| { x + y })
}
pub fn main() {
let mut adder = make_adder(3);
let z = (*adder)(2);
println!("{}", z);
assert_eq!(z, 5);
}
|