Lesson contents

Store a value

Give a number a name so you can use it again.

Simple example

Start5
Result5
main.rs
fn main() {
    let seats: i64 = 5;
    println!("{}", seats);
}
Output
5
Advertisements

Everyday examples

A bus has 12 seats. Five are taken. How many seats are free?

Start12 − 5
Result7
main.rs
fn main() {
    let seats: i64 = 12;
    let taken: i64 = 5;
    println!("{}", (seats - taken));
}
Output
7
Run the example
Terminal
rustc main.rs
./main
Official documentation