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

Copy Markdown View Source

Comprehensions, as values and as loops.

A comprehension used as a value is an iterator pipeline: each generator filters and binds its items in one filter_map, later generators nest through flat_map, and the result is collected into the type expected, or the collection into: names. Run for its effects, a comprehension is nested for loops, and for ..., reduce: acc is a loop updating acc.

Summary

Functions

A collect() given the type it collects into, when Rust cannot infer it.

The type a binding collects into: its own, or a list of what Rust infers for a slice.

A comprehension split into its qualifiers and its options, into:, reduce:, and do:.

Lowers a comprehension used as a value, collecting into expected_type when known.

Lowers a comprehension run for its effects, as nested for loops.

Lowers for ..., reduce: acc as a loop updating acc.

Functions

collect_as(lowered, type)

A collect() given the type it collects into, when Rust cannot infer it.

collect_target(type)

The type a binding collects into: its own, or a list of what Rust infers for a slice.

comprehension_parts(arg)

A comprehension split into its qualifiers and its options, into:, reduce:, and do:.

lower_comprehension(expression, expected_type, context)

Lowers a comprehension used as a value, collecting into expected_type when known.

lower_for_loop(list, body, context)

Lowers a comprehension run for its effects, as nested for loops.

lower_for_reduce_expr(expression, context)

Lowers for ..., reduce: acc as a loop updating acc.

lower_for_reduce_expr(other, return_type, context)