Exploring Rust - Part 1 (Setup: Atom, Racer)

May 14, 2016  

Exploring Rust

Everyone seems to be talking about Rust lately, so I’d thought I’d give it a shot and write something in it. The exploration begins with setting up the rust compiler (rustc), and setting up atom with various rust packages (linter, racer, and syntax highlighting).

Environment Setup

Installing the Rust Compiler (rustc)

Fetch the latest stable rust binaries (As of writing this 1.17.0):

$ curl https://sh.rustup.rs -sSf | sh

Rust comes with a language package manager called Cargo, I will be using it to install a package called racer for auto completion in atom.

Installing Racer

$ export PATH=$PATH:/home/$USER/.cargo/bin
$ cargo install racer

Atom Packages

Package Configuration: Racer requires RUST_SRC_PATH to be set to the location of your rust source, which can be downloaded and set like the following:

$ git clone https://github.com/rust-lang/rust.git
$ export RUST_SRC_PATH=/home/$USER/rust/src

“Ok, so I’ve opened a new .rs file and now its throwing errors at me!” - Make sure you’ve set the correct paths in Atom’s racer package, so just Ctrl+,, open the racer package, and set the paths. Mine are the following:

Rust Racer Package Configuration

And to test it out in your new rust source file, try out std:: you should get some auto complete!

Rust in Atom using Racer

Writing Rust

If you’re used to higher level languages, rust might be slightly daunting - Then again it’s probably not as bad as learning C/C++ the first time…

You can sometimes get helpful information using

$ rustc --explain EXXXX

Alternatively, the official webified version.

Happy rusting! Check out my other rust articles

Further Reading