RustQ.Meta.Lower.Collection (rustq v1.0.0-rc.19)

Copy Markdown View Source

Keyed collections, HashMap, BTreeMap, HashSet, and BTreeSet, as RustQ.Meta.Lower.Map and RustQ.Meta.Lower.MapSet lower them.

Elixir never changes a collection, so a function returning an updated one takes it only where nothing uses it afterwards, and otherwise updates a copy:

{ let mut rustq_updated = scores; rustq_updated.insert(name, 1); rustq_updated }

Summary

Functions

A key or item passed by reference, borrowed unless it already is one.

Whether a value is copied as cheaply as it is borrowed: a number, atom, reference, or tuple of them.

The keyed collection a type is, or is a reference to, with its key and value types.

The keyed collection collection is, by its type.

The type of a HashMap from key to value.

collection to take: itself at its last use, otherwise a copy.

A value read out of a collection: copied when that costs nothing, otherwise cloned.

The type of a HashSet of item.

An update of collection: statements receives the variable holding the collection, or a copy of it when collection is still in use, and the block returns that variable.

Types

keyed()

@type keyed() ::
  {:map, RustQ.Meta.Type.t(), RustQ.Meta.Type.t()} | {:set, RustQ.Meta.Type.t()}

Functions

borrowed(expression, type, context)

A key or item passed by reference, borrowed unless it already is one.

copy?(type)

@spec copy?(RustQ.Meta.Type.t() | nil) :: boolean()

Whether a value is copied as cheaply as it is borrowed: a number, atom, reference, or tuple of them.

keyed(type)

@spec keyed(RustQ.Meta.Type.t() | nil) :: keyed() | nil

The keyed collection a type is, or is a reference to, with its key and value types.

keyed_of(collection, context)

@spec keyed_of(Macro.t(), RustQ.Meta.Lower.Stdlib.Lowering.Context.t()) ::
  keyed() | nil

The keyed collection collection is, by its type.

map(key, value)

The type of a HashMap from key to value.

owned(collection, context)

collection to take: itself at its last use, otherwise a copy.

read_out(option, type)

A value read out of a collection: copied when that costs nothing, otherwise cloned.

set(item)

The type of a HashSet of item.

updated(collection, statements, context)

An update of collection: statements receives the variable holding the collection, or a copy of it when collection is still in use, and the block returns that variable.