Structs
The following code shows basic use of a struct.
Comma separation is optional in struct initialization and definition.
Point
is thus defined as a data structure containing two float fields x
and y
.
You can define instances of Point
like so:
Struct fields are always mutable. You can access fields of a struct like this:
Wu does not use .
for field access, because doing so would be gross.
We can also implement methods on our structs. This will feel very familiar for people with Rust experience.
Self
aliases whatever struct type you're implementing on.
Last updated