Loading...
Loading...

Rust Installation and Setup Guide

Get started with Rust programming - from installation to your first project. Includes verification steps and interactive quizzes.

1. Why Rust?

Key Features:

  • Memory safety without garbage collection
  • Blazingly fast performance
  • Zero-cost abstractions
  • Excellent tooling (Cargo, rustfmt, clippy)

Pre-Installation Quiz

Rust is particularly good for:

  • Rapid prototyping like Python
  • Systems programming and performance-critical applications
  • Frontend web development

2. Installing Rust

All Platforms (Recommended)

# Install rustup (Rust toolchain installer)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Follow the on-screen instructions
# This installs:
# - rustc (compiler)
# - cargo (package manager)
# - rustup (toolchain manager)

Windows Specific

# 1. Download rustup-init.exe from rustup.rs
# 2. Run installer
# 3. Install Visual Studio Build Tools when prompted

Installation Quiz

What does rustup install by default?

  • rustc, cargo, and rustup
  • Only the Rust compiler
  • Just the package manager

3. Verify Your Installation

# Check Rust version
rustc --version
# Should return something like: rustc 1.65.0 (897e37553 2022-11-02)

# Check Cargo version
cargo --version
# cargo 1.65.0 (4bc8f24d3 2022-10-20)

# Check installation components
rustup show

Verification Quiz

Which command shows installed toolchains?

  • rustc --list
  • rustup show
  • cargo check

4. Create Your First Project

# Create new project
cargo new hello_world
cd hello_world

# Project structure:
# hello_world/
# ├── Cargo.toml  # Project manifest
# └── src/
#     └── main.rs # Entry point

# Build and run
cargo run
# Output: Hello, world!

Project Quiz

Where is the main function located in a new Cargo project?

  • Cargo.toml
  • src/main.rs
  • target/debug/

5. Essential Development Tools

rustfmt (Code Formatter)

# Install
rustup component add rustfmt

# Format your code
cargo fmt

clippy (Linter)

# Install
rustup component add clippy

# Run linter
cargo clippy

Tools Quiz

What does cargo fmt do?

  • Compiles the project
  • Formats your code according to Rust style guidelines
  • Runs all tests

6. IDE Configuration

VS Code (Recommended)

  1. Install rust-analyzer extension
  2. Install Better TOML for Cargo.toml
  3. Install CodeLLDB for debugging

Other Editors

  • IntelliJ IDEA with Rust plugin
  • Neovim with coc-rust-analyzer
  • Emacs with lsp-mode

IDE Quiz

Which VS Code extension provides Rust language support?

  • Rust Language
  • rust-analyzer
  • Rust Helper

7. Keeping Rust Updated

# Update Rust toolchain
rustup update

# Update specific components
rustup component add rust-src  # For documentation

# Check for outdated dependencies
cargo outdated

Maintenance Quiz

How do you update your Rust installation?

  • cargo update
  • rustup update
  • rustc --upgrade
0 Interaction
0 Views
Views
0 Likes
×
×
×
🍪 CookieConsent@Ptutorials:~

Welcome to Ptutorials

$ Allow cookies on this site ? (y/n)

top-home