Distinct structure types
Structures with identical fields are not assignable to each other:SomeA and SomeB have identical layouts, they represent distinct types.
Contextual type inference
The compiler infers types from context. In the example below, the compiler determines that{ ... } has type StoredInfo based on the parameter type:
Explicit type hints
Explicit type hints are available. In addition to the plain{ ... } syntax, the form StructName { ... } can be used. The snippet below is equivalent to the previous example:
Methods
Methods are declared as extension functions:self parameter, a method will be static. By default, self is immutable. The form mutate self enables mutation.
Serialization prefixes
Serialization prefixes do not affect typing or layout. The syntaxstruct (PREFIX) Name { ... } specifies a serialization prefix. The prefix affects only the binary representation; all other aspects remain unchanged.
Structure syntax
Structure syntax includes:- shorthand field syntax
{ x, y }; - default field values (
a: int32 = 10); privateandreadonlyfields;- serialization prefixes (opcodes).