Lesson 1 - Hello World
Let’s start with one of the most important programs in programming: Hello World!
fn main() {
println!("Hello, world!");
}
When you run the code, it should display “Hello, world!”
Lets break down the code deeper:
fn tells rust that we are defining a function.
A function is a block of code that performs a particular task. In our case, it displays “Hello, world!”
main is a special function.
When you run an executable Rust program, execution begins inside main.
Curly braces define the body of a function. Everything between them belongs to that function.
println! prints information to the terminal.
println! is a macro, rather than an ordinary function.
You don't need to understand macros yet. For now, just remember that println! is used to print text.
"Hello, world!" is a string literal.
It represents text.
A semicolon (;) marks the end of a statement.