Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(dead_code)]
- #![allow(unused_variables)]
- #![allow(unused_assignments)]
- use std::collections::*;
- fn do_something(mapping: &HashMap<u64, String>, backup: &str) -> &str {
- for i in 0..3 {
- let maybe_v = mapping.get(&i);
- match maybe_v {
- Some(v) => return &v,
- }
- }
- backup
- }
- fn main() {
- let mut words = HashMap::new();
- words.insert(4, "four".to_owned());
- words.insert(5, "five".to_owned());
- let second = String::new("nothingelse");
- let res = do_something(&words, &second);
- println!("got {:?}", res);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement