Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created April 7, 2014 21:35
Show Gist options
  • Save bstrie/10062436 to your computer and use it in GitHub Desktop.
Save bstrie/10062436 to your computer and use it in GitHub Desktop.
use std::iter::{Iterator, FromIterator};
fn map<T, IT: Iterator<T>, U, IU: FromIterator<U>>(fun: |T|->U, coll: IT) -> IU {
let mut acc = Vec::new();
for elt in coll.move_iter() { // error: type `IT` does not implement any method in scope named `move_iter`
acc.push(fun(elt));
}
acc.move_iter().collect()
}
fn main() {
let x = map(|x| x+2, ~[1u,2,3]);
println!("{:?}", x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment