Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pass function as argument - hello world

pass function as a parameter to another function

fn main() {
    //hello();
    call(hello);
    call(world);
}

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

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

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