Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Lazy iterator, iterator adaptor?

También llamado: lazy iterator · iterator adaptor

Definition 9.4 University Computer Science — Year 2 · Capítulo 9 — Functional Programming

A Rust iterator is lazy: it computes the next element only when next is called. An iterator adaptor (map, filter, take, …) wraps an iterator into a new one and does no work when created; a consumer (sum, collect, count, a for loop) calls next until the end or until it has enough.

A lazy pipeline is pulled by its consumer. collect asks take for an element, which asks filter, which asks map until one passes; after two, take stops asking, and 320 is never mapped.
A lazy pipeline is pulled by its consumer. collect asks take for an element, which asks filter, which asks map until one passes; after two, take stops asking, and 320 is never mapped.
Leer en el capítulo →