Gavin Wiggins

About   /   Archive   /   Contact


Compile and Run a Rust File

Written on November 14, 2022

Below is the contents of a simple Rust program contained in a file named sayhello.rs.

// Contents of sayhello.rs that prints text to the screen.

fn main() {
    println!("Hello there");
}

To compile and run the file use the rustc command in the terminal.

# Compile a file
$ rustc sayhello.rs

# Run the compiled file to print text to the screen
$ ./sayhello
Hello there

Gavin Wiggins © 2025
Made on a Mac with Genja. Hosted on GitHub Pages.