Arrays and structs
Structs
Use a struct to give related fields a single type.
struct Point { x: i32, y: i32 }
fn main() -> i32 {
let point = Point::{ x = 40, y = 2 };
return point.x + point.y;
}terminal
hopper run demo src
Use the struct’s name and field names when constructing it. Struct values move when passed by value. A struct can contain other structs or arrays, but not itself by value. Reference fields are not supported yet.