The starting point of every Rust program is itself a function fn called the main() function, which can be further subdivided into separate functions for reuse of code or better code organization. Rust doesn't care in which order these functions are defined, but it is nice to put the function main() at the start of the code to get a better overview. Rust has incorporated many features of traditional functional languages; we will see examples of that in Chapter 5, Higher Order Functions and Error-Handling.
Let's start with a basic function example:
// from Chapter 3/code/functions.rs fn main() { let hero1 = "Pac Man"; let hero2 = "Riddick"; greet(hero2); greet_both(hero1, hero2); } fn greet(name: &str) { println!("Hi mighty {}, what brings you here?", name); } fn greet_both(name1: &str, name2: &...