2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2015-01-02 15:30:26 -05:00
|
|
|
// Test that the call operator autoderefs when calling to an object type.
|
|
|
|
|
|
|
|
use std::ops::FnMut;
|
|
|
|
|
2019-05-28 14:47:21 -04:00
|
|
|
fn make_adder(x: isize) -> Box<dyn FnMut(isize)->isize + 'static> {
|
2015-02-15 09:52:21 +01:00
|
|
|
Box::new(move |y| { x + y })
|
2015-01-02 15:30:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let mut adder = make_adder(3);
|
|
|
|
let z = adder(2);
|
|
|
|
println!("{}", z);
|
|
|
|
assert_eq!(z, 5);
|
|
|
|
}
|