]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-call-sugar-object-autoderef.rs
1 // run-pass
2 // Test that the call operator autoderefs when calling to an object type.
3
4 use std::ops::FnMut;
5
6 fn make_adder(x: isize) -> Box<dyn FnMut(isize)->isize + 'static> {
7     Box::new(move |y| { x + y })
8 }
9
10 pub fn main() {
11     let mut adder = make_adder(3);
12     let z = adder(2);
13     println!("{}", z);
14     assert_eq!(z, 5);
15 }