Guest User

Untitled

a guest
Jan 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. fn print_string(string: String) {
  2. println!("String: {}", string);
  3. }
  4.  
  5. fn close_over_string(string: String) -> impl Fn() -> () {
  6. move || print_string(string)
  7. }
  8.  
  9. fn main() {
  10. let string = String::from("hello, world"); // in actual use case, comes from config file.
  11. let x = close_over_string(string);
  12. x();
  13. }
Add Comment
Please, Sign In to add comment