Post

Hello, World in Rust

Install Rust

Refer Setup Rust for installation.

You can also refer official Rust documentation

Create new project with cargo

Open terminal and run following

1
2
cargo new hello-world
cd hello-world
1
2
3
fn main() {
    println!("Hello, world!");
}

Run application

1
2
3
4
5
6
cargo run

# Output
  Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/hello-world`
  Hello, world!

Conclusion

Above is a simple Hello, World program in rust, which iself will not do anything other than printing a static text. Using cargo we can easily create rust projects with proepr code structure without any manual effort.

Code

Rust Hello, World on GitHub

This post is licensed under CC BY 4.0 by the author.