// run-pass #![allow(non_camel_case_types)] trait vec_utils { fn map_(x: &Self, f: F) -> Vec where F: FnMut(&T) -> U; } impl vec_utils for Vec { fn map_(x: &Vec , mut f: F) -> Vec where F: FnMut(&T) -> U { let mut r = Vec::new(); for elt in x { r.push(f(elt)); } r } } pub fn main() { assert_eq!(vec_utils::map_(&vec![1,2,3], |&x| x+1), [2,3,4]); }