# `RustQ.Meta.Lower.Collection`
[🔗](https://github.com/elixir-crab/rustq/blob/v1.0.0-rc.19/lib/rustq/meta/lower/collection.ex#L1)

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 }

# `keyed`

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

# `borrowed`

```elixir
@spec borrowed(
  Macro.t(),
  RustQ.Meta.Type.t(),
  RustQ.Meta.Lower.Stdlib.Lowering.Context.t()
) ::
  RustQ.Rust.AST.expr()
```

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

# `copy?`

```elixir
@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`

```elixir
@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`

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

The keyed collection `collection` is, by its type.

# `map`

```elixir
@spec map(RustQ.Meta.Type.t(), RustQ.Meta.Type.t()) :: RustQ.Meta.Type.t()
```

The type of a `HashMap` from `key` to `value`.

# `owned`

```elixir
@spec owned(Macro.t(), RustQ.Meta.Lower.Stdlib.Lowering.Context.t()) ::
  RustQ.Rust.AST.expr()
```

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

# `read_out`

```elixir
@spec read_out(RustQ.Rust.AST.expr(), RustQ.Meta.Type.t()) :: RustQ.Rust.AST.expr()
```

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

# `set`

```elixir
@spec set(RustQ.Meta.Type.t()) :: RustQ.Meta.Type.t()
```

The type of a `HashSet` of `item`.

# `updated`

```elixir
@spec updated(
  Macro.t(),
  (RustQ.Rust.AST.expr() -&gt; [RustQ.Rust.AST.stmt()]),
  RustQ.Meta.Lower.Stdlib.Lowering.Context.t()
) :: RustQ.Rust.AST.expr()
```

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
