bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/Rust/Rust Tutorial
Rust•Rust Tutorial

Rust Get Started

Runnable example

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

Install Rust

However, if you want to download and install rust, you can go to rust-lang.org and follow the instructions there.

Or, if you are using the terminal, you can run:

curl https://sh.rustup.rs -sSf | sh

Check Installation

After installing, check if Rust is installed correctly by running:

rustc --version

The output will look something like this, depending on your version number:

rustc 1.86.0 (05f9846f8 2025-03-31)

Create a New Project

Use Cargo to create a new Rust project:

cargo new my_project

The output will look something like this:

Creating binary (application) `my_project` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

This creates a folder called my_project with the following files:

  • Cargo.toml : Project settings
  • src/main.rs : Main Rust file

The main.rs file contains this default code:

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

Build and Run the Project

cd my_project

Then build and run the project

cargo run

The output should be

Congratulations! You have just run your first Rust program.

Previous

Rust Introduction

Next

Rust Syntax

This chapter

Overview
20

Lessons

46m

Read time

1. Rust Tutorial2. Rust Introduction3. Rust Get Started4. Rust Syntax5. Rust Output (Print Text)6. Rust Comments7. Rust Variables8. Rust Data Types9. Rust Constants10. Rust Operators11. Rust Booleans12. Rust If .. Else Conditions13. Rust Match14. Rust Loops15. Rust While Loops16. Rust For Loop17. Rust Functions18. Rust Scope19. Rust Strings20. Rust Ownership

On this page

Install RustCheck InstallationCreate a New ProjectBuild and Run the Project