-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add Result::map_or_default
and Option::map_or_default
#141659
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
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
r? @Amanieu |
@@ -858,6 +858,36 @@ impl<T, E> Result<T, E> { | |||
} | |||
} | |||
|
|||
/// Maps a `Result<T, E>` to a `U` by applying function `f` to the contained | |||
/// value if the result is [`Ok`], otherwise if [`Err`], returns the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// value if the result is [`Ok`], otherwise if [`Err`], returns the | |
/// value if the result is [`Ok`], otherwise if [`Err`] returns the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the documentation of unwrap_or_default
there is a comma:
That's fair. Let's just keep the wording consistent for now. @bors r+ rollup |
Rollup of 8 pull requests Successful merges: - #140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`) - #140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`) - #141252 (gvn: bail out unavoidable non-ssa locals in repeat) - #141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored) - #141551 (Make two transmute-related MIR lints into HIR lint) - #141591 (ci: fix llvm test coverage) - #141647 (Bump master `stage0` compiler) - #141659 (Add `Result::map_or_default` and `Option::map_or_default`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #141659 - tkr-sh:map-or-default, r=Amanieu Add `Result::map_or_default` and `Option::map_or_default` Closes: #138068 _This PR has been recreated because of the inactivity of the author (Cf. #138068 (comment)
Rollup of 8 pull requests Successful merges: - rust-lang/rust#140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`) - rust-lang/rust#140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`) - rust-lang/rust#141252 (gvn: bail out unavoidable non-ssa locals in repeat) - rust-lang/rust#141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored) - rust-lang/rust#141551 (Make two transmute-related MIR lints into HIR lint) - rust-lang/rust#141591 (ci: fix llvm test coverage) - rust-lang/rust#141647 (Bump master `stage0` compiler) - rust-lang/rust#141659 (Add `Result::map_or_default` and `Option::map_or_default`) r? `@ghost` `@rustbot` modify labels: rollup
Add `Result::map_or_default` and `Option::map_or_default` Closes: rust-lang#138068 _This PR has been recreated because of the inactivity of the author (Cf. rust-lang#138068 (comment)
Rollup of 8 pull requests Successful merges: - rust-lang#140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`) - rust-lang#140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`) - rust-lang#141252 (gvn: bail out unavoidable non-ssa locals in repeat) - rust-lang#141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored) - rust-lang#141551 (Make two transmute-related MIR lints into HIR lint) - rust-lang#141591 (ci: fix llvm test coverage) - rust-lang#141647 (Bump master `stage0` compiler) - rust-lang#141659 (Add `Result::map_or_default` and `Option::map_or_default`) r? `@ghost` `@rustbot` modify labels: rollup
Closes: #138068
This PR has been recreated because of the inactivity of the author (Cf. #138068 (comment))