This tutorial walks you through the smallest useful Rust project: a binary crate managed by Cargo. You will create a new project, inspect Cargo.toml and src/main.rs, run a Hello World program, and build the executable from the command line. The goal is to help you understand the basic files and commands you will use every time you start a new Rust app.
Write Your First Rust Program
Create a new Cargo project, run Hello World, and learn the basic workflow for building and executing Rust binaries.
Start the tutorialA simple Rust project workflow
What you will do in this guide
Create a Cargo project
Use Cargo to generate a new binary project in one command. This gives you a ready-made folder structure and the files needed to begin immediately.
Understand the project files
Learn the role of Cargo.toml as the package manifest and src/main.rs as the program entry point. These two files are the core of a basic Rust application.
Run Hello World
Edit main.rs and run the program with Cargo to print a simple message. This confirms that your project is set up correctly and ready to execute.
Build a binary
Compile the project into an executable using Cargo build. You will see how Rust turns your source code into a runnable binary.
Use basic Cargo commands
Practice the everyday workflow with cargo new, cargo run, cargo build, and cargo check. These commands cover the essentials for starting and testing a small Rust program.
Common questions from beginners
What does Cargo do?
Cargo creates projects, manages the package manifest, compiles your code, and runs your binary. It is the standard command-line tool for most Rust workflows.
Which file should I edit first?
Start with src/main.rs. That file contains the entry point for a basic binary program, while Cargo.toml describes the project itself.
How do I run the program?
Use cargo run from the project directory. Cargo will build the project if needed and then execute the resulting binary.
What is out of scope for this tutorial?
This guide stays focused on the first binary project and basic Cargo commands. It does not cover installation, language fundamentals, or advanced package management.