Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashMap;
- type Commands = HashMap<String, fn(u32, u32) -> u32>;
- fn add(a: u32, b: u32) -> u32 {
- a + b
- }
- fn main() {
- let mut command = Commands::new();
- command.insert("add".to_string(), add);
- println!("{}", command["add"](2, 3));
- }
Add Comment
Please, Sign In to add comment