Skip to content

Instantly share code, notes, and snippets.

@killercup
Created January 18, 2017 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killercup/cdabc6c2cac0cd069ec7522bf136983b to your computer and use it in GitHub Desktop.
Save killercup/cdabc6c2cac0cd069ec7522bf136983b to your computer and use it in GitHub Desktop.
fn fst<T1, T2>((t1, _t2): (T1, T2)) -> T1 {
t1
}
fn snd<T1, T2>((_t1, t2): (T1, T2)) -> T2 {
t2
}
fn main() {
let xs = vec![42, 43, 44, 45];
let ys: Vec<usize> = xs.iter().enumerate().map(fst).collect();
println!("{:?}", ys);
let xs = vec![42, 43, 44, 45];
let ys: Vec<&i32> = xs.iter().enumerate().map(snd).collect();
println!("{:?}", ys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment