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

Copy Markdown View Source

Which variables lowered Rust changes, so their bindings are mut: a let whose value a later statement changes in place, a closure argument its body changes, and an owned argument a rebinding updates in place, as scores = Map.put(scores, name, 1) becomes scores.insert(name, 1);.

Summary

Functions

Marks the lets and closure arguments of a lowered body that it changes mut.

Marks the variables of pattern in mutable_vars mut.

The variables a lowered body changes in place through a statement calling a mutating method on them, as scores.insert(name, 1); does where scores was rebound to its update.

Whether a method changes its receiver, as std collections' &mut self methods do.

A binding of a collection to its update, map = Map.put(map, key, value), as the in-place change of that collection, map.insert(key, value);, where the update takes the collection at its last use; any other statement unchanged.

Functions

infer_mutability(body)

@spec infer_mutability([RustQ.Rust.AST.stmt()]) :: [RustQ.Rust.AST.stmt()]

Marks the lets and closure arguments of a lowered body that it changes mut.

mark_mutable_pattern_vars(pattern, mutable_vars)

@spec mark_mutable_pattern_vars(RustQ.Rust.AST.pat(), MapSet.t(atom())) ::
  RustQ.Rust.AST.pat()

Marks the variables of pattern in mutable_vars mut.

mutated_variables(body)

@spec mutated_variables([struct()]) :: MapSet.t(atom())

The variables a lowered body changes in place through a statement calling a mutating method on them, as scores.insert(name, 1); does where scores was rebound to its update.

mutating_method?(method)

@spec mutating_method?(atom()) :: boolean()

Whether a method changes its receiver, as std collections' &mut self methods do.

updated_in_place(let)

@spec updated_in_place(RustQ.Rust.AST.stmt()) :: RustQ.Rust.AST.stmt()

A binding of a collection to its update, map = Map.put(map, key, value), as the in-place change of that collection, map.insert(key, value);, where the update takes the collection at its last use; any other statement unchanged.