Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 935 Bytes

README.md

File metadata and controls

45 lines (30 loc) · 935 Bytes

episode-001

Where we compile our first program

Setup

The following needs to be prepared:

  • A terminal with access to rustc
  • An editor, we use Sublime Text

Script

We have installed Rust so lets use it to compile a rust program. Open a file hello.rs and enter the following code

fn main() {
	println!("Hello, World!");
}

This creates a function with the name main, which Rust will pick up as the entry point of the program.

Head over to the terminal, enter the directory in which you created the file and type the following command

rustc hello.rs

This will create an executable file called hello. Run it by executing

./hello

It prints

Hello, World!

to the console.

And there you have it, you compiled your first Rust program.