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!