Structs
Syntax
Struct :
struct
IDENTIFIER{
StructField*
StructMethod*
}
StructField :
pub
? IDENTIFIER:
TypeStructMethod :
Function
A struct is a nominal struct type defined with the keyword struct
.
An example of a struct
item and its use:
struct Point {
pub x: u256
pub y: u256
}
fn pointy_stuff() {
let mut p: Point = Point(x: 10, y: 11)
let px: u256 = p.x
p.x = 100
}
Builtin functions:
abi_encode()
encodes the struct as an ABI tuple and returns the encoded data as a fixed-size byte array that is equal in size to the encoding.