练习题三
Closed this issue · 0 comments
chyyuu commented
练习三:
关于闭包的定义使用。改进下面的代码,要求正确编译&输出
9
x is 8
fn apply<F>(f: F) where
F: Fn() {
f();
}
fn main() {
let x = 7;
let print = || { x+=2; println!("{}", x);};
x=8;
apply(print);
println!("x is {}",x);
}