Layout
We'll cover the following...
Look at this piece of code:
Press + to interact
fn main() {println!("Hello, world!");{let name = "Michael";println!("Nice to meet you, {}!", name);}println!("Have a great day");}
Now compare it to this one:
Press + to interact
fn main(){println!("Hello, world!");{let name = "Michael"; println!("Nice to meet you, {}!", name);} println!("Have a great day"); }
These programs do exactly the same thing, but the first is significantly easier to read, and frankly prettier. That’s because it’s following Rust’s recommended rules of layout and indentation. The computer doesn’t care about these rules at all. They’re to make the code easier to work with for you, the dear programmer.
There ...