Statements
Statements in Rust are instructions that perform actions without returning a value. They are commonly used for variable declarations, function definitions, and managing control flow. For example, when you declare a variable using thelet keyword, you are executing a statement.
Consider the following simple example where let y = 6 declares a variable y and assigns it the value 6:
y but does not produce a value. Function definitions, such as the entire main function, are also regarded as statements.
Since statements do not return values, they cannot be used directly in value contexts. For example, the following code will produce an error because a let statement is used where a value is expected:
Expressions
Expressions, on the other hand, evaluate to a value. Nearly all Rust code is made up of expressions, including arithmetic operations, function calls, and code blocks that yield values.
Arithmetic Expressions
Arithmetic expressions are a basic example of expressions that evaluate to a value. For instance, the expression5 + 6 evaluates to 11:
sum.
Code Blocks as Expressions
In Rust, code blocks delimited by curly braces{} can serve as expressions if they yield a value. The return value of a block is determined by its last expression, provided the expression is not terminated by a semicolon.

4 because the last expression x + 1 does not have a semicolon:
x + 1 would convert the expression into a statement, which would not yield a value.
Control Flow Constructs as Expressions
Rust’s control flow constructs, such asif and match, are also expressions because they yield a value based on the branch that is executed. This feature enables these constructs to be used in value contexts.

if expression can evaluate to different values depending on the condition:
match expression evaluates patterns and assigns the corresponding value based on the pattern matched.
Summary
Understanding the difference between statements and expressions is fundamental to mastering Rust programming. Statements perform actions without returning values, whereas expressions evaluate to values and can be used where a value is required. Mastering these concepts leads to more concise and efficient code.
Mastering statements and expressions lays a strong foundation for advanced Rust programming and enables you to write more expressive and higher quality code.