Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #![allow(dead_code)]
  2. #![allow(unused_variables)]
  3. #![allow(unused_assignments)]
  4.  
  5. use std::collections::*;
  6.  
  7. fn do_something(mapping: &HashMap<u64, String>, backup: &str) -> &str {
  8. for i in 0..3 {
  9. let maybe_v = mapping.get(&i);
  10. match maybe_v {
  11. Some(v) => return &v,
  12. }
  13. }
  14.  
  15. backup
  16. }
  17.  
  18. fn main() {
  19. let mut words = HashMap::new();
  20.  
  21. words.insert(4, "four".to_owned());
  22. words.insert(5, "five".to_owned());
  23.  
  24. let second = String::new("nothingelse");
  25.  
  26. let res = do_something(&words, &second);
  27.  
  28. println!("got {:?}", res);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement