Compile and run a Rust program from scratch

Pascal Precht
InstructorPascal Precht
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

In this lesson we’ll create our first “Hello World” Rust program from scratch and will learn how to compile it using rustc.

Instructor: [00:00] Start by creating a file main.rs and create a function main() using the fn keywords. This is the function that will be run when we execute our program. To output "Hello, World" we use println!, or print line, which takes a string. We give it "Hello, World." Then we save the file.

[00:25] Next, we compile the program using the rustc compiler. Once that is done, we'll see that there is a new file called main, which can be executed straight from the command line.