Rust — Get Started
Installing Rust — one tool does everything
Rust installs through rustup, the official version manager:
Windows → download and run rustup-init.exe from rustup.rs
macOS → curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Linux → same curl command
The installer also sets up:
- rustc — the compiler itself
- cargo — build tool, package manager, test runner
- std docs — offline documentation
Verify everything landed correctly:
$ rustc --version
rustc 1.79.0
$ cargo --version
cargo 1.79.0
Updating later is one command: rustup update.
Your first program — the Cargo way
Real Rust projects are always managed by Cargo. Skip single-file mode; start as you mean to continue:
$ cargo new hello_rust
$ cd hello_rust
Cargo creates this structure:
hello_rust/
├── Cargo.toml ← project manifest (name, version, dependencies)
└── src/
└── main.rs ← your code lives here
Cargo.toml — the manifest
[package]
name = "hello_rust"
version = "0.1.0"
edition = "2021"
TOML is the config format. Dependencies you add later live here too.
src/main.rs — the code
fn main() {
println!("Hello, world!");
}
fn main()— every program starts hereprintln!— a macro (the!gives it away), not a regular function; it generates code that prints its arguments- The line ends with a semicolon — expressions vs statements matter in Rust (covered soon)
Running it
$ cargo run
Compiling hello_rust v0.1.0
Finished dev [unoptimized] target(s)
Hello, world!
cargo run = compile + execute in one step.
Build without running:
$ cargo build # debug build → target/debug/
$ cargo build --release # optimized build → target/release/
Release builds skip debug checks and apply optimizations — dramatically faster, but slower to compile.
What just compiled behind the scenes
main.rs → [cargo calls rustc] → binary → executed by OS directly
No virtual machine, no interpreter at runtime. The output is a native executable you can copy to any matching platform.
Editor setup
VS Code + rust-analyzer extension is the community standard:
- Inline type hints on every variable
- Error squiggles as you type (before compiling)
- One-click suggestions for compiler fixes
Install rust-analyzer, open the project folder, done.
The development loop
edit src/main.rs → cargo run → read output/errors → repeat
Compile times on small projects are seconds. Errors stop the build but never corrupt anything — fix and rerun freely.
Mini Practice
- Install rustup; confirm both
--versioncommands work. cargo new intro; add a secondprintln!line;cargo run.- Break it: remove the semicolon after println, run, read the error fully.
- Run
cargo build --release; find the binary in target/release and run it directly. - Peek inside target/ — that's all build artifacts; safe to delete anytime.
Next: syntax →
Related Topics
Frequently Asked Questions about Get Started
What is Get Started in Rust?
Get Started is a fundamental concept in Rust. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Get Started?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Get Started.
Why is Get Started important in Rust?
Get Started is essential for Rust development. Understanding this concept will help you write better code and solve real-world problems more effectively.