Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. lazy_static! {
  4. pub static ref MAP: HashMap<&'static str, &'static str> = {
  5. let mut map = HashMap::new();
  6. map.insert("key", "value");
  7. map
  8. };
  9. }
  10.  
  11. fn main() {
  12. invert()
  13. }
  14.  
  15. fn invert() {
  16. let x = MAP.into_iter().map(|(k, v)| (v, k)).collect::<HashMap<_, _>>();
  17.  
  18. println!("{:?}", x.get("value"));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement