// ./src/fn/closures/anonymity.md // `F` must implement `Fn` for a closure which takes no // inputs and returns nothing - exactly what is required // for `print`. fn apply(f: F) where F: Fn() { f(); } fn part0() { let x = 7; // Capture `x` into an anonymous type and implement // `Fn` for it. Store it in `print`. let print = || println!("{}", x); apply(print); } pub fn main() { part0(); }