liveBook · Manning

Entry point

As explained in Learn Rust in a Month of Lunches

The main function is the entry-point function that Rust starts when running an executable program.

An entry point is where an executable program begins. In Rust, the main function, written as fn main(), starts the program without receiving arguments. Its code block contains the first statements Rust runs. section 1.6

A minimal Rust entry point

fn main() { println!("Hello, world!"); } Here, fn declares a function, main names the entry point, () shows that it takes no arguments, and the braces hold its code. section 1.6

fn main() {
    println!("Hello, world!");
}

Inspect the smallest runnable Rust program and see the entry point connected to output. section 1.6

How Learn Rust in a Month of Lunches covers it

How deep it goes
Defines main, empty arguments, and its code block, but stops short of runtime startup internals.
Examples
Uses a minimal Hello, world! program to show main executing println!.
What it assumes
Teaches function syntax and argument notation from zero while assuming only a runnable Rust program.
What you can do after
Understand where a Rust executable begins and place its initial statements inside main.
How it connects
Connects the entry point to functions, arguments, code blocks, and println! output.

Also explained in

Compare how 10 books explain entry point →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Rust in a Month of Lunches. The section links point to the parts of the book it draws on.