Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Rust Fundamentals

Lesson 2 of 50 · rust

Setting up Rust and Cargo

Duration: 20 minutes

Setting up Rust and Cargo\n\nRust provides rustup (version manager) and cargo (package manager and build system). Together, they handle everything needed to build Rust applications.\n\n## Installation (macOS, Linux, Windows WSL)\n\nRust provides a simple installation script:\n\nbash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n\n\nThis script automatically:\n- Downloads the appropriate Rust toolchain for your OS\n- Installs rustup, cargo, rustc, and documentation\n- Sets up your PATH environment variable\n\nVerify installation:\n\nbash\nrustc --version # Rust compiler version\ncargo --version # Package manager version\nrustup --version # Version manager\n\n\n## Updating Rust\n\nRust releases stable versions every 6 weeks. Keep updated:\n\nbash\nrustup update\nrustup toolchain list # See installed toolchains\nrustup install nightly # Install nightly builds\nrustup default stable # Set default toolchain\n\n\n## Creating Your First Project\n\nbash\ncargo new hello_world --bin # Binary project\ncargo new my_lib --lib # Library project\ncd hello_world\n\n\n### Generated Structure\n\n\nhello_world/\n├── Cargo.toml # Project manifest\n├── Cargo.lock # Dependency lock file\n└── src/\n └── main.rs # Entry point\n\n\n## Building and Running\n\nbash\ncargo build # Debug build\ncargo build --release # Optimized release build\ncargo run # Build and run\ncargo check # Verify without building binary\ncargo test # Run tests\ncargo fmt # Auto-format code\ncargo clippy # Linter for improvements\ncargo doc --open # Generate & open documentation\n\n\nDebug builds compile faster but run slower. Release builds take longer but produce significantly faster binaries.

Previous: Introduction to RustNext: Your First Program (Hello World)