rust-training
rust-training copied to clipboard
Function syntax
We should add a slide early on just to talk about basic function syntax, with parameters and an optional return type.
I think the very first code snippet should show it.
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
}