Pass function as argument - hello world


pass function as a parameter to another function


examples/advanced-functions/pass-function-as-argument-simple/src/main.rs
fn main() {
    //hello();
    call(hello);
    call(world);
}

fn hello() {
    println!("Hello");
}

fn world() {
    println!("World");
}

fn call(my_function: fn() -> ()) {
    my_function();
}

Hello
World