Hi
In Code Listing 12-22, the snippet shows the following
let results = if config.case_sensitive {
search(&config.query, &contents)
} else {
search_case_insensitive(&config.query, &contents)
};
If I put semicolons at the end of the statements for the function calls "search" or "search_case_insensitive", I will get an error about if and else having incompatible types and a message suggesting to remove the semicolon.
Then in Code Listing 13-5
let expensive_closure = |num| {
println!("calculating slowly...");
thread::sleep(Duration::from_secs(2));
num
};
Semicolons are allowed for the "println!" and "sleep" calls.
My main question is both listings are using let statements, so why is it that putting a semicolon for the example in Code Listing 12-22 will throw an error but it doesn't for Code Listing 13-5? I am sure I misunderstood/missed some concepts but not sure what they are.