rust-training icon indicating copy to clipboard operation
rust-training copied to clipboard

Function syntax

Open jonathanpallant opened this issue 7 months ago • 1 comments

We should add a slide early on just to talk about basic function syntax, with parameters and an optional return type.

jonathanpallant avatar May 13 '25 10:05 jonathanpallant

I think the very first code snippet should show it.

listochkin avatar May 15 '25 12:05 listochkin

We have this in overview.md. Maybe that's enough.

fn main() {
    let random_number = generate_random_number();
    let mut my_choice = 10;
    my_choice += random_number;
    println!("{my_choice}");
}

fn generate_random_number() -> i32 {
    4 // chosen by dice roll, guaranteed to be random
}

jonathanpallant avatar May 20 '25 10:05 jonathanpallant