Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.