Before you can do anything using the Rust programming language, you’re going to need to acquire it—either for Windows or by using your terminal on Unix-like systems, where $
symbolizes input into the terminal:
$ curl https://sh.rustup.rs -sSf | sh
This will retrieve the required files and set up the latest version of Rust for you, no matter what system you’re on. For more information, see project page.
Note: Some Linux distributions (e.g. Arch Linux) provide rustup
as a package, which can be installed instead. And although many Unix-like systems provide rustc
and cargo
as separate packages, it is still recommended to use rustup
instead since it makes it much easier to manage multiple release channels and do cross-compilation.
We can now check to see if Rust was in fact successfully installed onto our computers by running the following command either in our terminal—if on UNIX—or the command prompt—if on Windows:
$ rustc --version
Should this command be successful, the version of Rust’s compiler installed onto our computers will be displayed before our eyes.
With Rust comes Cargo, which is a build tool used for managing your Rust packages and projects. To make sure this, too, is present on your computer, run the following inside the console—console referring to either terminal or command prompt depending on what system you’re on:
$ cargo --version
Just like the equivalent command for the Rust compiler, this will return and display the current version of Cargo.
To create your first Cargo project, you may head to Cargo.
Alternatively, you could compile programs directly using rustc
as shown in Minimal example.