Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stabilize Result::map_or #66570

Open
wants to merge 2 commits into
base: master
from
Open

Conversation

@lzutao
Copy link
Contributor

lzutao commented Nov 20, 2019

r? @SimonSapin
Closes #66293

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Nov 20, 2019

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Nov 20, 2019

@lzutao

This comment has been minimized.

Copy link
Contributor Author

lzutao commented Nov 23, 2019

@rust-highfive rust-highfive assigned sfackler and unassigned SimonSapin Nov 23, 2019
@lzutao lzutao closed this Nov 25, 2019
@lzutao lzutao reopened this Nov 25, 2019
@lzutao

This comment has been minimized.

Copy link
Contributor Author

lzutao commented Nov 25, 2019

@rust-highfive rust-highfive assigned dtolnay and unassigned sfackler Nov 25, 2019
@lzutao lzutao force-pushed the lzutao:stabilize-result-map_or branch from 7bbac33 to 1f3d350 Nov 25, 2019
@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Nov 27, 2019

Thanks @lzutao!

This is a brand new API (#66292) but it is a sensible complement to Result::map_or_else which we have decided already to stabilize in 1.41.0 (#66322) and matches Option::map_or which has existed since 1.0.0.

impl<T, E> Result<T, E> {
    pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
        match self {
            Ok(t) => f(t),
            Err(_) => default,
        }
    }
}

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Nov 27, 2019

Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 2, 2019

☔️ The latest upstream changes (presumably #66944) made this pull request unmergeable. Please resolve the merge conflicts.

@lzutao lzutao force-pushed the lzutao:stabilize-result-map_or branch from 1f3d350 to 93438fd Dec 2, 2019
@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Dec 5, 2019

@Amanieu @Kimundi @withoutboats waiting for your approval on this

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Dec 5, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.