Hello World with Cargo



cargo new hello-world
cd hello-world


examples/intro/hello-world/src/main.rs
fn main() {
    println!("Hello, world!");
}

examples/intro/hello-world/Cargo.toml
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

$ cargo run
   Compiling hello-world v0.1.0 (/home/gabor/work/slides/rust/examples/hello-world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.34s
     Running `target/debug/hello-world`
Hello, world!

It also created a file called Cargo.lock and a folder called target.