Setting Up Your Environment
Before we can move forward to learning Rust, we need to have a working local environment. There are a lot of online tools to run Rust code, but since the target here is to start pairing, local is best.
The preferred way to setup your local Rust toolchain is with rustup. Go ahead and install that, then come back here. You can check if you have it installed by checking which version it is:
$ rustup --version
You should see something like this as the output:
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.68.0-nightly (cc47b0699 2023-01-08)`
If you get an error, try closing your terminal and opening a new one; the installation adds itself to your path and that doesn't get reloaded automatically.
The Rust language moves quickly, so we can benefit from a lot of improvements by using the nightly toolchain instead of stable. Set it as your default like so:
$ rustup default nightly
And then make sure it's up to date:
$ rustup update
That's all you need, and you should be up and running now! Let's go take a look at our first Rust code.
Rust Analyzer
Before you start writing too much Rust, you will want to also install rust-analyzer. This is a tool which provides a lot of nice features in your IDE or editor, like completions and refactoring help. Crucially to me, it also can display inline types annotations for inferred types, which can greatly aid understanding of Rust programs.
It's by no means necessary for working with Rust, but if you're going to do any work with Rust it's an extremely helpful tool.
Instructions on how to configure it are out of scope of this guide, as it will be different for every editor.
Exercise: Look up instructions for your editor of choice and set it up to use Rust Analyzer.