2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-05-29 00:26:56 -05:00
|
|
|
use std::ops::FnMut;
|
|
|
|
|
2015-01-12 09:27:25 -06:00
|
|
|
fn call_it<F:FnMut(i32,i32)->i32>(y: i32, mut f: F) -> i32 {
|
2015-01-05 13:07:10 -06:00
|
|
|
f(2, y)
|
2014-05-29 00:26:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2015-02-01 11:44:15 -06:00
|
|
|
let f = |x: i32, y: i32| -> i32 { x + y };
|
2014-05-29 00:26:56 -05:00
|
|
|
let z = call_it(3, f);
|
|
|
|
println!("{}", z);
|
|
|
|
assert_eq!(z, 5);
|
|
|
|
}
|