Title here
Summary here
Our first program will print the classic “hello world” message. Here’s the full source code.
fn main() {
println!("hello world");
}
To run the program, put the code in hello_world.rs
and use cargo run
.
$ cargo new hello_world --bin
$ cd hello_world
$ cargo run
hello world
Sometimes we’ll want to build our programs into binaries. We can do this using cargo build --release
, which creates an optimized binary.
$ cargo build --release
$ ls target/release/
hello_world
We can then execute the built binary directly.
$ ./target/release/hello_world
hello world
Now that we can run and build basic Rust programs, let’s learn more about the language.