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.
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
@type keyed() :: {:map, RustQ.Meta.Type.t(), RustQ.Meta.Type.t()} | {:set, RustQ.Meta.Type.t()}
Functions
@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.
@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.
@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.
@spec keyed_of(Macro.t(), RustQ.Meta.Lower.Stdlib.Lowering.Context.t()) :: keyed() | nil
The keyed collection collection is, by its type.
@spec map(RustQ.Meta.Type.t(), RustQ.Meta.Type.t()) :: RustQ.Meta.Type.t()
The type of a HashMap from key to value.
@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.
@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.
@spec set(RustQ.Meta.Type.t()) :: RustQ.Meta.Type.t()
The type of a HashSet of item.
@spec updated( Macro.t(), (RustQ.Rust.AST.expr() -> [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.