Structs

Syntax
Struct :
   struct IDENTIFIER : NEWLINE
   INDENT
   StructField*
   DEDENT

StructField :
   IDENTIFIER : Type

A struct is a nominal [struct type] defined with the keyword struct.

An example of a struct item and its use:

struct Point:
    x: u256
    y: u256

p = Point {x: 10, y: 11}
px: u256 = p.x;

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.