Skip to content

core::iter::from_fn and core::iter::successors documentation does not explain callback function signature #135087

Closed
@rick-de-water

Description

@rick-de-water

Location

core::iter::from_fn
core::iter::successors

Summary

Both of these functions take callback methods that return an Option<T>. However, nowhere is actually described that this Option<T> is used to detect the end of the iterator (i.e. return Some while there are items, return None when at the end). I was able to deduce how things worked eventually by looking at the examples, but I was definitely a bit confused at first.

There should be a clear description on what the callback is expected to return, not just when the callback is called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions