Skip to content

[ER] Iterator::reduce docs example code #81819

Closed
@leonardo-m

Description

@leonardo-m

I think it's better in general for the standard docs to contain examples that are easy to understand, but are also realistic usages of functions and features. An example of this is in slice::binary_search that shows how to insert an item to a sorted vector while maintaining sort order.

So I think the docs of Iterator::reduce could be improved with a more real usage example (to replace the current find_max example). And I think such docs should also say that reduce is useful when your binary operation doesn't have an identity element (or when you don't want to use it for some reason, like efficiency, etc).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions