Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. fn main() {
  4. let map = [(1, "foo"), (2, "bar")].iter().cloned().collect::<HashMap<_, _>>();
  5. dbg!(&map);
  6. let map = map.into_iter().map(|(k, v)| (v, k)).collect::<HashMap<_, _>>();
  7. dbg!(&map);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement