Setting Up Rustlings

Learn to set up Rustlings

cClassroom with some desks and chalkboards

Sometimes, reading sucks, and I say this as an avid reader.

Honestly, it does, and technical writing is just something that can be incredibly dense. And if you're like me, you prefer to learn by messing around with things and by breaking them, rather than just reading a 300+ page book about a programming language.

Thankfully, we are not alone, and we have Rustlings.

Rustlings is a set of teensy little exercises designed to teach and test individual concepts. You do them in order and they progressively get more complex as they build on what you've done before. They are not unlike the good ol' Ruby Exercises and the Mythical Creatures, in particular.

So let's get to the point of this article, which is to learn how to set up Rustlings. We are going to presume that you have the Xcode Command Line Tools installed, as well as Rust.

We get Rustlings on our computers like so:

curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash

What this does is that it gets the installation script from GitHub and runs it using bash on our computer. It will download everything we need to a rustlings directory and install itself. This may take a hot second depending on your internet connection and how fast your computer is.

Once that all finishes, just enter the rustlings directory and type in rustlings to bring up a getting started message.

From here, as recommended to you from Rustlings, you will want to run in your terminal rustlings watch.

What this does is that it starts a program that will scan your rustlings directory and look to see if there are any changes made to the files.

As we start, rustlings watch wants us to go into the exercises\intro directory and look at intro1.rs. This file is just a sample, and there's nothing wrong in here to fix.  

The whole idea behind this is that the point of these exercises are to mess around. Once you've got everything solved, you will still have the opportunity to play. rustlings watch will not move onto the next exercise until you are ready.

You can tell it that you are ready to move on by removing the commented line,

// I AM NOT DONE

In this intro1.rs file, you can play with the println! statements, and when you are done, removing the commented out I AM NOT DONE will prompt rustlings watch to go ahead and look at the next exercise in the sequence, exercises/intro/intro2.rs

If you have not deduced it yet, comments in rust start with //.

With rustlings watch you can ask for a hint with hint, access the help menu with help and you can quit it by either typing in quit or with a CTRL+C

Subscribe to Rust for Rubyists

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe