Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashMap;
- fn main() {
- let c: &'static str = "C";
- let mut map: HashMap<&'static str, Box<Fn()>> = HashMap::new();
- map.insert("A", Box::new(|| { println!("A") }));
- map.insert("B", Box::new(test));
- map.insert("C", Box::new(|| println!("{}", c)));
- map.get("A").unwrap()();
- map.get("B").unwrap()();
- map.get("C").unwrap()();
- }
- fn test() {
- println!("B");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement