tao_of_rust::ch02::function
pub fn closure_math<F: Fn() -> i32>(op: F) -> i32
Basic usage:
pub fn math<F: Fn() -> i32>(op: F) -> i32 { op() } let a = 2; let b = 3; assert_eq!(math(|| a + b), 5); assert_eq!(math(|| a * b), 6);Run