rust hello world program
Here's a simple "Hello, World!" program in Rust:
rust hello world program
fn main() { println!("Hello, World!"); }
To run the program, save it to a file with a .rs
extension and use the rustc
command to compile it. Then, you can run the resulting executable file:
$ rustc hello.rs $ ./hello Hello, World!
Alternatively, you can use the cargo
command to build and run the program in one step:
$ cargo run --bin hello
Compiling hello v0.1.0 (/path/to/hello)
Finished dev [unoptimized + debuginfo] target(s) in 0.34s
Running target/debug/hello
Hello, World!