Flashcard Rust: First steps
Rust is one of the coolest systems programming lanugage on the block, let’s dip our feet in it.
Setup
Hopefully, you are using Linux. To install Rust, use:
> curl https://sh.rustup.rs -sSf | sh
Rustup is a tool that is used to install Rust, the above script downloads and installs rustup
first and then installs Rust.
Ahoy!
Let’s create a directory to keep our source files:
> mkdir ~/rust_sources
> cd ~/rust_sources
Our first program, to say ahoy!
> mkdir ahoy; cd ahoy
> touch main.rs
Open main.rs
and add the following line:
fn main() {
println!("ahoy ahoy!");
}
Save the file and run rustc main.rs
, thats it! We have compiled our first rust program.
There should be a file named main
in the same directory main.rs is in, execute it using:
/main
.! ahoy ahoy
Now that you have written 2 lines of rust, do read