Skip to content

Commit 84ef889

Browse files
authored
Rollup merge of rust-lang#66570 - lzutao:stabilize-result-map_or, r=Dylan-DPC
stabilize Result::map_or r? @SimonSapin Closes rust-lang#66293
2 parents c34ea91 + 93438fd commit 84ef889

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/libcore/result.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,14 @@ impl<T, E> Result<T, E> {
520520
/// # Examples
521521
///
522522
/// ```
523-
/// #![feature(result_map_or)]
524523
/// let x: Result<_, &str> = Ok("foo");
525524
/// assert_eq!(x.map_or(42, |v| v.len()), 3);
526525
///
527526
/// let x: Result<&str, _> = Err("bar");
528527
/// assert_eq!(x.map_or(42, |v| v.len()), 42);
529528
/// ```
530529
#[inline]
531-
#[unstable(feature = "result_map_or", issue = "66293")]
530+
#[stable(feature = "result_map_or", since = "1.41.0")]
532531
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
533532
match self {
534533
Ok(t) => f(t),

src/librustc_mir/transform/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
517517
let left_bits = place_layout.size.bits();
518518
let right_size = r.layout.size;
519519
let r_bits = r.to_scalar().and_then(|r| r.to_bits(right_size));
520-
if r_bits.ok().map_or(false, |b| b >= left_bits as u128) {
520+
if r_bits.map_or(false, |b| b >= left_bits as u128) {
521521
let lint_root = match &self.source_scopes[source_info.scope].local_data {
522522
ClearCrossCrate::Set(data) => data.lint_root,
523523
ClearCrossCrate::Clear => return None,

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14561456
pcx.method_name = Some(method_name);
14571457
pcx.assemble_inherent_candidates();
14581458
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
1459-
.ok().map_or(None, |_| {
1459+
.map_or(None, |_| {
14601460
pcx.pick_core()
14611461
.and_then(|pick| pick.ok())
14621462
.and_then(|pick| Some(pick.item))

src/libterm/terminfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl TermInfo {
7474
Err(..) => return Err(Error::TermUnset),
7575
};
7676

77-
if term.is_err() && env::var("MSYSCON").ok().map_or(false, |s| "mintty.exe" == s) {
77+
if term.is_err() && env::var("MSYSCON").map_or(false, |s| "mintty.exe" == s) {
7878
// msys terminal
7979
Ok(msys_terminfo())
8080
} else {

0 commit comments

Comments
 (0)