Guest User

Untitled

a guest
Jul 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. type Commands = HashMap<String, fn(u32, u32) -> u32>;
  4.  
  5. fn add(a: u32, b: u32) -> u32 {
  6. a + b
  7. }
  8.  
  9. fn main() {
  10. let mut command = Commands::new();
  11. command.insert("add".to_string(), add);
  12.  
  13. println!("{}", command["add"](2, 3));
  14. }
Add Comment
Please, Sign In to add comment