fn main() { 3.times(|i| { println!("Ferris ate {} cookies", i); }); } trait ChristmasExt { fn times(&self, f: F); } // We would somehow implement this for all integer types, but this is just // a proof of concept, so one impl for `i32` is fine. impl ChristmasExt for i32 { fn times(&self, mut f: F) { for i in 0..*self { f(i); } } }