OneBite.Dev - Coding blog in a bite size

Hello World in Rust

Write our Hello World in Rust. It requires compiling and running

Create a new file in your project called and write the following

fn main() {
    println!("Hello, world!");

In terminal window (mac/linux) run


For windows

> rustc
> .\main.exe

There we go! hello World!

As you notice. Rust requires compiling, before we can run the program. rustrc is the keyword for compiling.

After running rustrc, if you see your project dir, you can see there is main file besides our source code from before It’s the executable file.

← Getting started with Rust...
What is Cargo in Rust... →