-
-
Save jpastuszek/b316b4af832e4ac2aaa5baa0ed1a5708 to your computer and use it in GitHub Desktop.
Rust: call closure once and only once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn bar<F, R>(f: F) -> R where F: FnOnce() -> R { | |
//f(); // used after move | |
f() // need to get R somehow | |
} | |
fn main() { | |
bar(|| { | |
println!("foo!"); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment