Preface: In this post we won’t be doing much, just install Rust and pick an editor.
Code: none
Getting set up to start coding in Rust is pretty simple. Rust has a tool called
Rustup
which we can use to update our local Rust toolchain.
⠀⠀⠀⠀⠀ We’ll head to https://www.rust-lang.org/tools/install. Once there, we copy the following command, which we run in a terminal on the computer that we’ll be coding on:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Configuration: On some operating systems you might have to configure the PATH variable.
Windows: If you’re on Windows please refer to this page on alternative ways to install Rust.
Check installation
We can check that our installation was successful by running:
rustc --version
Updating Rust
Now, since we have Rustup installed, we can update to the latest version of Rust:
rustup update
Stable and Nightly
Rust is continuously being improved. Every two weeks there.
There are two main branches, stable
(consolidated) and nightly
(experimental).
⠀⠀⠀⠀⠀ If we’re building a project, using a new experimental feature in the nightly
branch, there are no guarantee (from the Rust dev team) that the feature will be included in the next stable version, or ever for that matter. Because of that we need to be careful in using nightly in client facing production software.
⠀⠀⠀⠀⠀ Regardless, if we want to use the nightly branch, we need to swith to it.
Switching back to the stable branch is done the same way:
rustup show # which toolschains are installed and which is default
rustup install nightly
rustup default nightly # switch toolchain to nightly
rustup default stable # switch back to stable
rustup # get a list of other commands
tip: By placing a
rust-toolchain.toml
file in our project root, we can specify these things more formally, by including a[toolchain] channel = "nightly"
.
Package Manager
Rust has an amazingly handy utility called cargo
. We can use it to install
crates, which is Rust’s name for external dependencies/packages/libraries.
We can also use cargo to build/compile our Rust code project.
Pick an editor
There are lots of editors that we can use to code Rust. Personally, I really like Microsoft’s free editor, Code, so that’s what I’ll use. Two other editors I’d like to mention are Zed from Zed Industries, and RustRover from JetBrains. But use whatever editor you like.
The End
Okay, so this post was mostly about me getting started with a series of posts, aimed at refreshing/revising my Rust skills.