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

Rust hello world function

  • fn

  • We can declare functions with other names using the fn keyword.

  • The relative location of the functions does not matter. There is no need to defined headers.

  • We can call the functions by writing their name followed by a pair of parenthesis.

fn main() {
    greet();
}

fn greet() {
    println!("Hello World!");
}