Skip to content

bits-of-rust/episode-001

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages