Introduction
In this lab, a Rust program is primarily composed of statements which can include variable bindings and expressions. Statements are designated by a ;
, while expressions are followed by a ;
and can be used as values in assignments. Additionally, blocks are also considered expressions and can be assigned to local variables, with the last expression serving as the assigned value. However, if the last expression within a block ends with a semicolon, the return value will be ()
.
Note: If the lab does not specify a file name, you can use any file name you want. For example, you can use
main.rs
, compile and run it withrustc main.rs && ./main
.