Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn print_string(string: String) {
- println!("String: {}", string);
- }
- fn close_over_string(string: String) -> impl Fn() -> () {
- move || print_string(string)
- }
- fn main() {
- let string = String::from("hello, world"); // in actual use case, comes from config file.
- let x = close_over_string(string);
- x();
- }
Add Comment
Please, Sign In to add comment