Lazy generator expressions

Parenthesized comprehension syntax creates an Iterator<T> instead of an eager collection. Its sources, guards, and produced value run only as downstream pulls demand them.

Generators are synchronous, fused, and single-pass. A terminal such as collect makes the eager boundary visible; take can stop before entering unused work.

fn main() {
  let even_squares = (x * x for x in 0..1000 if x % 2 == 0)
  println(even_squares.take(3).collect())
}
Output & diagnostics
Expected:
[0, 4, 16]
Ctrl/⌘+Enter runs the current lesson.