Structures

New structure type can be declared using struct keyword:

struct Point<T> { // structure with generic argument
var x: T;
var y: T;
init(x: T,y: T) {
this.x = x;
this.y = y;
}
}

You can implement interfaces in structure declaration:

struct Foo: Display {
fun format(stream: mut String*) { // `format` is a member of `Display` interface
stream.write("Foo");
}
}

‚Äč