Skip to content

Instantly share code, notes, and snippets.

@jpastuszek
Forked from anonymous/playground.rs
Last active September 14, 2016 08:53
Show Gist options
  • Save jpastuszek/b316b4af832e4ac2aaa5baa0ed1a5708 to your computer and use it in GitHub Desktop.
Save jpastuszek/b316b4af832e4ac2aaa5baa0ed1a5708 to your computer and use it in GitHub Desktop.
Rust: call closure once and only once
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