What is this Function Expression termed which just uses curly braces?

I came across one of the example code in eframe Rust GUI Library, and I wanted to know the name/term by which we refer to, when we use this feature of Rust.

I have coded a very simple example of the similar feature used in eframe library.

fn main() {
    let mut var = 5;
    let expr_var = {
        let mutable_var = &mut var; 
        *mutable_var = 6;
        (*mutable_var as f32) / 2.0
    println!("{}", expr_var); // prints 3

Please explain me the term for this cool expression used for evaluating expr_var. If possible, a link to the Rust documentation for this specific feature, will be really useful.

Thanks in advance for helping this beginner, who has just started learning Rust.

It's a block expression.

If the block ends with an expression (without a semicolon) then the value of the block expression is the value of that last expression in the block.


Thank you Tomek for the help. I have started liking this Rust community.. It is very much helpful.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.