Is the `struct` declaration an expression?

struct Point {
    x: i32,
    y: i32,
}
fn main() {
    let p = Point {x: 20, y: 20};
    println!("{},{}", p.x, p.y);
}

I find that the 'Point' declaration doesn't have a ';'. So It is an expression? If yes, are expressions without semicolon valid? In order to verify, I worte the code below:

fn main() {
    let p = struct Point { x: i32, y: i32 };
    println!("{}", p == () );
}

It can't work.
If it is a kind of expression, how can I get its value?
Or it is something else other than expression and statement, is declaration absolute independent code building block like expression and statement?
Thanks for your help!

struct is an item, like fn is an item. Note that fn main doesn't have ; either.

There are items, statements, and expressions. Items have {}, statements have ;, expressions have none. "declaration" is not in the same class as "expression".

1 Like

Thanks very much.