Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created December 27, 2018 21:25
Show Gist options
  • Save rust-play/05cc49bb7e29b90aa58d56f218697cd4 to your computer and use it in GitHub Desktop.
Save rust-play/05cc49bb7e29b90aa58d56f218697cd4 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn call<F>(a: i64, b: i64, c: F) -> i64 where F: Fn(i64, i64) -> i64 {
c(a, b)
}
fn main() {
println!("{}", call(10, 10, |a, b| a + b));
println!("{}", call(20, 10, |a, b| a - b));
println!("{}", call(30, 10, |a, b| a * b));
println!("{}", call(40, 10, |a, b| a / b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment