-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implemented map_or_else for Result<T, E> #53777
Conversation
r? @aidanhs (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
23d388e
to
52b046f
Compare
This comment has been minimized.
This comment has been minimized.
src/libcore/result.rs
Outdated
/// assert_eq!(x.map_or_else(|e| k * 2, |v| v.len()), 42); | ||
/// ``` | ||
#[inline] | ||
#[stable(feature = "result_map_or_else", since = "1.30.0")] |
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.
@rust-lang/libs should probably sign this off before this is added as a stable feature (unless that happened and I missed it -- sorry)
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.
Nothing like that has happened, as far as I know - I just slapped a value in there to make it compile.
The error value now includes the type of the success. The success value now includes the type of the error.
52b046f
to
71b16d8
Compare
My understanding of libs team policy is this: this method should be marked as |
Oh, good to know. Where should the tracking issue be created - is the current issue in |
Yep, we create tracking issues on this repository. In fact, you can probably just make #53268 the tracking issue and we'll label it properly. The unstable attribute takes an You can chose the feature name: the one you've chosen seems fine. |
map_or_else is now correctly labelled unstable and points to the tracking issue on rust-lang/rust
This comment has been minimized.
This comment has been minimized.
Ping from triage @aidanhs / @rust-lang/libs: This PR requires your review. |
@bors: r+ Thanks @ivanbakel and sorry for the delay! |
📌 Commit 79408c3 has been approved by |
@bors rollup |
…xcrichton Implemented map_or_else for Result<T, E> Fulfills rust-lang#53268 The example is ripped from `Option::map_or_else`, with the types corrected.
Rollup of 15 pull requests Successful merges: - #52514 (Fix a few AMDGPU related issues) - #53703 (Document .0 to unpack integer from Wrapping) - #53777 (Implemented map_or_else for Result<T, E>) - #54031 (A few cleanups and minor improvements to rustc_passes) - #54046 (Update documentation for fill_buf in std::io::BufRead) - #54064 (`&CStr`, not `CStr`, is the counterpart of `&str`) - #54072 (Stabilization change for mod.rs) - #54073 (docs: Use dollar sign for all bash prompts) - #54074 (simplify ordering for Kind) - #54085 (Remove documentation about proc_macro being bare-bones) - #54087 (rustdoc: Remove generated blanket impls from trait pages) - #54106 (Reexport CheckLintNameResult) - #54107 (Fix typos in libstd hash map) - #54136 (Update LLVM to fix GlobalISel dbg.declare) - #54142 (Recover proper regression test for issue #16278.) Failed merges: r? @ghost
Fulfills #53268
The example is ripped from
Option::map_or_else
, with the types corrected.