rust-ape-example/src/bin/fn_closures_input_functions.rs
2022-09-07 10:49:49 +05:30

27 lines
468 B
Rust

// ./src/fn/closures/input_functions.md
// Define a function which takes a generic `F` argument
// bounded by `Fn`, and calls it
fn call_me<F: Fn()>(f: F) {
f();
}
// Define a wrapper function satisfying the `Fn` bound
fn function() {
println!("I'm a function!");
}
fn part0() {
// Define a closure satisfying the `Fn` bound
let closure = || println!("I'm a closure!");
call_me(closure);
call_me(function);
}
pub fn main() {
part0();
}