summaryrefslogtreecommitdiffstats
path: root/tests/ui/unboxed-closures/unboxed-closures-boxed.rs
blob: 3f550fd04259f583b43de4d6068b623c61c223fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// run-pass

use std::ops::FnMut;

 fn make_adder(x: i32) -> Box<dyn FnMut(i32)->i32+'static> {
    Box::new(move |y: i32| -> i32 { x + y }) as
        Box<dyn FnMut(i32)->i32+'static>
}

pub fn main() {
    let mut adder = make_adder(3);
    let z = adder(2);
    println!("{}", z);
    assert_eq!(z, 5);
}