Guest User

Untitled

a guest
Jul 15th, 2019
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::collections::HashMap;
  2.  
  3. fn main() {
  4. let c: &'static str = "C";
  5. let mut map: HashMap<&'static str, Box<Fn()>> = HashMap::new();
  6. map.insert("A", Box::new(|| { println!("A") }));
  7. map.insert("B", Box::new(test));
  8. map.insert("C", Box::new(|| println!("{}", c)));
  9.  
  10. map.remove("A").unwrap()();
  11. map.remove("B").unwrap()();
  12. map.remove("C").unwrap()();
  13. }
  14.  
  15. fn test() {
  16. println!("B");
  17. }
RAW Paste Data