Your First Rust Program
Let’s write your first Rust program.
1. Navigate to Your Project:
cd hello_rust
2. Edit src/main.rs
:
fn main() {
println!("Hello, world!");
}
fn main()
defines the entry point of your program. println!
is a macro used to print to the console.
3. Run Your Program:
cargo run
This compiles and runs your code. You should see:
Hello, world!
Congratulations! You’ve written your first Rust program.