Skip to content

Iterator adapters (.zip, .map, .filter, …) exist only for built-in iterator types; a user type implementing Iter[T] has none (§13.3) #1746

Closed

Description

@ehartford

Spec: §13.2 ("for loops, .zip(), .peekable(), .windows() — all work as you'd expect"), §13.3 (collection operations over any Iter[T]).

Found by the #1725 g.pull() work: .zip(), .map() and the other iterator adapters are special-cased in codegen for the built-in iterator types only. A user type that implements Iter[T] — including std's new Pulled[T] from g.pull() — gets "unknown method" for them. The pull tests pair two pulled generators through a generic function over Iter[T] instead of a.zip(b).

Expected: every adapter §13.3 defines works on any Iter[T] implementor, written once in std over the trait rather than per built-in type in codegen (D65: the method set is a Sema/std fact, not a codegen special case).

Activity

  1. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by 9307016 (#1965): the §13.3 adapters are written once as iter_<name> fns in std.traits over any impl Iter[T]; Sema resolves recv.name(args) / recv |> name(args) on a type with a declared next() and no intrinsic adapter (built-in iterators keep their intrinsics). Fixture behav_1746_user_iter_adapters.w (zip/filter/map/collect/enumerate/fold/take/count/any/chain/take_while/position on a user Iter[T] and on Pulled). Battery green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions