How to Install Rust | HAHWUL
Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without having a garbage collector, making it useful for embedded and bare-metal development, integration with other languages, and writing low-level code like device drivers and operating systems.
Key Features
- Memory Safety Without Garbage Collection: Rust’s ownership system ensures memory safety and thread safety without needing a garbage collector.
- Zero-Cost Abstractions: Rust provides abstractions that compile to efficient code as if you’d written the low-level code by hand.
- Fearless Concurrency: Rust’s type system and ownership model guarantee thread safety, allowing you to eliminate many concurrency bugs at compile time.
- Type Inference: The compiler can often infer what type you mean, making static typing feel less burdensome.
- Pattern Matching: An elegant way to handle complex data and control flow.
- Modern Package Manager:
Cargo
handles dependencies, building, testing, and documentation.
Installation
Rust installation is managed through a tool called rustup
, which makes it easy to install and update Rust and associated tools.
Standard Installation
To install Rust on Linux, macOS, or another Unix-like OS, run this command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This command downloads a script and starts the installation. You might be prompted to customize your installation, but the default options are suitable for most users.
Post-Installation Steps
After installation completes, you’ll need to add Rust to your system PATH. The installer should offer to do this automatically, but if you need to do it manually, add this to your shell profile (like ~/.bashrc
or ~/.zshrc
):
export PATH="$HOME/.cargo/bin:$PATH"
Then restart your terminal or run source ~/.bashrc
(or your appropriate shell config file).
Verifying Installation
To verify that Rust was installed correctly, run:
rustc --version
cargo --version
Both commands should display their version information.
Installed Components
The installation includes:
rustc
: The Rust compilercargo
: Rust’s package manager and build systemrustup
: The Rust toolchain installer and version manager
Updating Rust
To keep Rust updated to the latest version, run:
rustup update
Uninstalling Rust
If you need to uninstall Rust and all its components, run:
rustup self uninstall
Next Steps
Now that you have Rust installed, you might want to:
- Read The Rust Book
- Explore Rust by Example
- Try the Rustlings course
- Check out crates.io for reusable packages
Source link