Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #[macro_use]
  2. extern crate lazy_static;
  3.  
  4. fn say_what(name: &str, func: fn(&str)) {
  5. func(name);
  6. }
  7.  
  8. fn test(string: &str) {
  9. println!("{}", string);
  10. }
  11.  
  12. fn foo(_: &str) {
  13. println!("foobar.");
  14. }
  15.  
  16. lazy_static! {
  17. static ref VEC: Vec<(&'static str, fn(&str))> = vec![("Hello, Rust!", test), ("null", foo)];
  18. }
  19.  
  20. fn main() {
  21. // let vec: Vec<(&str, fn(&str))> = vec![
  22. // ("Hello, Rust!", test),
  23. // ("null", foo)
  24. // ];
  25. for i in VEC.iter() {
  26. say_what(i.0, i.1);
  27. }
  28. }
Add Comment
Please, Sign In to add comment