Setting Up Rust: The Easy Way (No Sweat!)
Alright, so you’ve decided to take the leap into Rust—great choice! Now, before you start writing code that makes your computer feel like a superhero, let’s get Rust installed and ready to roll.
1. Installing Rust
Rust comes with a super handy tool called Rustup that makes installation a breeze. Follow these steps, and you’ll be coding in no time!
Windows
- Open a terminal (Command Prompt or PowerShell).
- Run this magical command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the on-screen instructions.
- Restart your terminal and verify Rust is installed:
rustc --version
macOS
- Open your terminal.
- Type this and press enter:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the instructions.
- Run this to ensure everything is working:
rustc --version
Linux
- Fire up your favorite terminal.
- Run:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the setup wizard.
- Check if Rust is installed:
rustc --version
2. Configuring Rust
Now that Rust is installed, let’s tweak a few settings to make your experience even better.
Updating Rust
Rust gets frequent updates, so keeping it fresh is a good idea:
rustup update
Setting the Default Rust Version
Want to use a specific Rust version?
rustup default stable
Or, if you need an older version:
rustup install 1.65.0
rustup default 1.65.0
Adding Components
Some Rust tools aren’t installed by default. Add them like this:
rustup component add clippy rustfmt
3. Testing Your Rust Installation
Let’s write a simple Rust program to make sure everything is working. Create a new file called main.rs
and add this:
fn main() {
println!("Hello, Rustaceans!");
}
Now, compile and run it:
rustc main.rs
./main
If you see Hello, Rustaceans!
, congratulations! You’re ready to roll with Rust!
0 Comments