Home / Docs / Standard library / Prelude

Entry

Release v0.4.0Edition 0.2 and later

A kind of the prelude, in scope in every module. Edition 0.2 and later.

una
pub kind Entry[K, V]
  key: K
  value: V

An entry of a map, as entries() lists them (spec/21 §1 rule 4).

Fields

See also

entries

Example

src/shop.unauna
module shop

--- One line of a stock report.
line(e: Entry[Text, Int]) -> Text = "{e.key}: {e.value}"

pub main() -> Unit
  uses @console: Console[print]
=
  let stock = empty_map().with(key: "lamp", value: 3).with(key: "desk", value: 1)
  for e in stock.entries()
    @console.print(line(e))

una run . prints:

Output
desk: 1
lamp: 3

Specification

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.