Module starlark::values::structs

source ·
Expand description

The struct type, an associative-map created with struct().

This struct type is related to both the dictionary and the record types, all being associative maps.

  • Like a record, a struct is immutable, fields can be referred to with struct.field, and it uses strings for keys.
  • Like a dictionary, the struct is untyped, and manipulating structs from Rust is ergonomic.

The struct() function creates a struct. It accepts keyword arguments, keys become struct field names, and values become field values.

ip_address = struct(host='localhost', port=80)
ip_address.port == 80

Structs§