Skip to content

Tracking Issue for #138068: Add Result::map_or_default and Option::map_or_default #138099

Open
@fpervaiz

Description

@fpervaiz

Feature gate: #![feature("result_option_map_or_default")]

This is a tracking issue for adding Result::map_or_default() and Option::map_or_default(). Open RFC rust-lang/rfcs#3148

Public API

// core::result

impl<T, E> Result<T, E> {
    pub fn map_or_default<U, F>(self, f: F) -> U
    where
        U: Default,
        F: FnOnce(T) -> U { .. }
}
// core::result

impl<T> Option<T> {
    pub fn map_or_default<U, F>(self, f: F) -> U
    where
        U: Default,
        F: FnOnce(T) -> U { .. }
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API 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