Installing Rust nightly

With rustup, the tool we installed in Chapter 1, Basics of Rust, it is very easy to install nightly:

rustup default nightly

Running this command will install the nightly version of the tools (cargo, rustc, and so on). Also, it will switch the corresponding commands to use the nightly version.

If you want to go back to the stable version, issue the following command:

rustup default stable

The nightly version is updated very frequently, so you might want to update it every week or more often. To do so, you need to run this command:

rustup update

This will also update the stable version if a new version was released (one stable version is released every 6 weeks).

Now that we are using Rust nightly, we're ready to create a new project:

cargo new rusic-relm --bin

Add the following dependencies in the Cargo.toml file:

[dependencies]
gtk = "^0.3.0"
gtk-sys = "^0.5.0"
relm = "^0.11.0"
relm-attributes = "^0.11.0"
relm-derive = "^0.11.0"

We still need gtk because relm is based on it. Let's add the corresponding extern crate statements:

#![feature(proc_macro)]

extern crate gtk;
extern crate gtk_sys;
#[macro_use]
extern crate relm;
extern crate relm_attributes;
#[macro_use]
extern crate relm_derive;

relm provides some macros, that's why we needed to add #[macro_use]. We'll start slowly by creating a simple window with relm.