Skip to content

Using to_iter instead of iter leads to unhelpful errors in iterators1 #2261

@MathsStan

Description

@MathsStan

The hint for iterators1 leads to the trait.Iterator documentation, where many of the examples use the to_iter method for obtaining the iterator. The compiler errors when using this method are unfriendly, and it is not clear that the iter method exists.

The simplest solution in my mind is to add a use of my_fav_fruits after the assert statements, to compel the compiler to throw an error about the array being consumed if using to_iter instead of iter.

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