How Do You Write a “Hello World” Command in Rust?

Problem scenario
You want to write a basic program in Rust to know you have it installed correctly. What do you do?

Solution

  1. Install Rust. If you need assistance, try this command:
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

2. Create a file called contint.rs with the following four lines:

// We recommend calling this contint.rs
fn main() {
    println!("Hello World!");
}
  1. Compile it with this command: rustc contint.rs
  2. Run the bytecode by using this command: ./contint

Leave a comment

Your email address will not be published. Required fields are marked *