• Home
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • TypeScript
      • Introduction to TypeScript
      • TypeScript Developer
    • React
      • Introduction to React
      • React Developer
    • Python
      • Introduction to Python
      • Python Developer
    • C++
      • Introduction to C++
      • C++ Developer
    • C Language
      • Introduction to C
      • C Developer
    • Rust
      • Introduction to Rust
      • Rust Developer
    • Zig
      • Introduction to Zig
      • Zig Developer
    • Linux Shell
      • Introduction to the Linux Shell
      • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Reading Grounds

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds
  • Featured on DanielLaunches

Courses

  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer

Newsletter

Subscribe to our free monthly newsletter, for a quick update on Python, JavaScript, and React news

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

Introduction to Rust - Lesson 1

Lesson 1 of 22

Hello World

Lesson Progress: 0%

Lesson Progress: 0%
Hello World
Lesson Incomplete
Lesson 1 of 22
Next: Comments →

Hello World is the first program most people write when learning a new programming language. In Rust, the println! macro is used to display text on the screen. The fn main()function is the entry point of every Rust program — it is where execution begins. Writing a Hello World program introduces you to the basic structure of a Rust project: defining a function, using a macro, and producing output. This simple exercise confirms that your Rust environment is set up correctly and that you understand the fundamental syntax. From here, you can build more complex programs by adding variables, functions, and control flow.

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

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • fn main() declares the main function, which is the starting point of every Rust program.
  • The body of the function is enclosed in curly braces { and }.
  • println! is a Rust macro that prints text followed by a newline.
  • The text "Hello, world!" is a string literal enclosed in double quotes.
  • Every statement in Rust ends with a semicolon ;.
Code Example
fn main() {
    let name = "Rust";
    println!("Hello, {}!", name);
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • let creates a new variable. Here name holds the string "Rust".
  • Rust infers the type of name as &str (a string slice) automatically.
  • The curly braces {} inside the string act as placeholders for values.
  • println!("Hello, !", name); replaces with the value of name.
  • Using variables in print statements lets you display dynamic content.
Code Example
fn main() {
    println!("Hello, world!");
    println!("Welcome to Rust.");
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • A Rust program can have multiple println! calls, each producing one line of output.
  • The statements run in order from top to bottom inside main.
  • The first println! prints Hello, world! and the second prints Welcome to Rust..
  • Each println! automatically adds a newline at the end of its output.
  • Printing multiple lines is how you display more than one piece of information to the user.
Code Example
fn greet() {
    println!("Hello, world!");
}
fn main() {
    greet();
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • You can define your own functions with fn followed by the function name and parentheses.
  • fn greet() defines a function named greet that prints a message.
  • main calls greet() by writing its name followed by parentheses.
  • When greet() is called, execution jumps to that function, runs its code, and returns.
  • Functions let you reuse code and keep your program organized.
Code Example
fn main() {
    let x = 42;
    println!("The answer is {}", x);
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • Variables can store numbers as well as text. Here x holds the integer 42.
  • Rust infers x as type i32 (a 32-bit integer) automatically.
  • The placeholder {} works for numbers just like it does for strings.
  • println!("The answer is ", x); inserts the value 42 into the printed text.
  • Combining text with variable values is a common way to display results to the user.
Code Example
fn main() {
    for i in 0..3 {
        println!("Hello {}", i);
    }
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

Rust Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • A for loop repeats a block of code a specific number of times.
  • 0..3 creates a range that produces the numbers 0, 1, and 2.
  • The loop variable i takes each value in the range, one at a time.
  • println!("Hello ", i); prints Hello 0, then Hello 1, then Hello 2.
  • Loops are a powerful way to repeat actions without writing the same code multiple times.

Test Incomplete

What macro does Rust use to print text to the screen?

Question #

1/15

Score

0/0 - 0.0 %