structs are a way to create your own data types (like in C).
naming convention for structs are starting with a capital letter and camel-cased.
like any variable binding, structs are immutable by default; unless you give them a mut in their binding.
Initialization of a data structure (struct, enum, union) can be simplified when fields of the data structure are initialized with variables of the same names as the fields.
Update syntax
you can also use the same type of copy syntax that you can do with Python and javascript
you can also see on the last couple lines is that you can use this for new or existing structs or with different structs
this .. syntax will copy over origin’s y and z value.
also if you do this:
solution
box2 is Box {x: 8, y: 8}
Tuple-like Structs
tuple structs are like normal structs but they don’t have named values.
you can also use tuple structs to create a “newtype” pattern.
creates your own “type” that lets you give more meaning to a variable.