Installing Rust and Setting Up Your Environment
Before writing Rust code, you need to install Rust and set up your development environment.
1. Install Rust:
Use the official installer rustup
which installs Rust, Cargo (Rust’s package manager), and related tools.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, run:
rustc --version
to verify Rust is installed.
2. Set Up an IDE:
- VS Code: Install the
rust-analyzer
extension for autocompletion, type checking, and more. - IntelliJ Rust: JetBrains’ Rust plugin for IntelliJ-based IDEs.
3. Create a New Project:
cargo new hello_rust
This creates a new project with a main.rs
file and a Cargo.toml
file to manage dependencies.