[][src]Function tao_of_rust::ch02::function::two_times

pub fn two_times() -> Box<dyn Fn(i32) -> i32>

闭包: 作为返回值(动态分发)

Basic usage:

fn two_times() -> Box<Fn(i32) -> i32> {
    let i = 2;
    Box::new(move |j| j * i)
}
let result = two_times();
assert_eq!(result(2), 4);Run