You must be here because you are interested in the Rust programming language. Great!
To get started with Rust, here are the absolute minimum steps you need to take to get up to speed. This setup is for macOS, since that is my primary development environment, but you can find information about Windows and Linux on the Rust website.
Open Terminal and install Rustup with curl
. This gets you both the Rust
compiler rustc
and the Cargo build tool. You can try Rust without Cargo
first, but be sure to check it out, because it does many useful things.
Install Visual Studio Code (or some other editor you like, preferably with Rust support for syntax coloring and code completion).
(Optional) Create a directory for your Rust projects and change there.
Create a new file and save it as hello.rs
.
(The Rust source file extension is .rs
.)
Edit the contents of the source file to read like this:
fn main() { println!("Hello, Rust!"); }
Compile the file with rustc hello.rs
. You should now have an executable file called
hello
(or hello.exe
in Windows).
Run the executable with ./hello
(or hello
in Windows).
It should print out the text Hello, Rust! in
your terminal:
% rustc hello.rs % ./hello Hello, Rust!
That's it! You have created and executed your first Rust program.
But there is more to come. Stay tuned!