Skip to content

Documentation on Result::map_or_else uses very unfortunate wording #88195

Closed
@orlp

Description

@orlp

The type signature of Result::map_or_else:

pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U where
    F: FnOnce(T) -> U,
    D: FnOnce(E) -> U, 

Note how default is the function that gets applied to the Err variant. Then, the docstring (emphasis mine):

Maps a Result<T, E> to U by applying a fallback function to a contained Err value, or a default function to a contained Ok value.

I think this is a very unfortunate choice of words and should be changed.

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