mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Remove unstable Result::into_ok_or_err
This commit is contained in:
parent
9c20b2a8cc
commit
83f081fc01
@ -14,7 +14,6 @@ index 06c7be0..359e2e7 100644
|
|||||||
@@ -75,7 +75,6 @@
|
@@ -75,7 +75,6 @@
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(unwrap_infallible)]
|
#![feature(unwrap_infallible)]
|
||||||
#![feature(result_into_ok_or_err)]
|
|
||||||
-#![feature(portable_simd)]
|
-#![feature(portable_simd)]
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
#![feature(once_cell)]
|
#![feature(once_cell)]
|
||||||
|
@ -86,17 +86,18 @@ where
|
|||||||
F: Fn(D) -> bool,
|
F: Fn(D) -> bool,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
Self::Seq(elts) => elts
|
Self::Seq(elts) => match elts.into_iter().map(|elt| elt.prune(f)).try_fold(
|
||||||
.into_iter()
|
Tree::unit(),
|
||||||
.map(|elt| elt.prune(f))
|
|elts, elt| {
|
||||||
.try_fold(Tree::unit(), |elts, elt| {
|
|
||||||
if elt == Tree::uninhabited() {
|
if elt == Tree::uninhabited() {
|
||||||
Err(Tree::uninhabited())
|
Err(Tree::uninhabited())
|
||||||
} else {
|
} else {
|
||||||
Ok(elts.then(elt))
|
Ok(elts.then(elt))
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
.into_ok_or_err(),
|
) {
|
||||||
|
Err(node) | Ok(node) => node,
|
||||||
|
},
|
||||||
Self::Alt(alts) => alts
|
Self::Alt(alts) => alts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|alt| alt.prune(f))
|
.map(|alt| alt.prune(f))
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
#![feature(
|
#![feature(alloc_layout_extra, control_flow_enum, decl_macro, iterator_try_reduce, never_type)]
|
||||||
alloc_layout_extra,
|
|
||||||
control_flow_enum,
|
|
||||||
decl_macro,
|
|
||||||
iterator_try_reduce,
|
|
||||||
never_type,
|
|
||||||
result_into_ok_or_err
|
|
||||||
)]
|
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -1771,40 +1771,6 @@ impl<T, E> Result<Result<T, E>, E> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Result<T, T> {
|
|
||||||
/// Returns the [`Ok`] value if `self` is `Ok`, and the [`Err`] value if
|
|
||||||
/// `self` is `Err`.
|
|
||||||
///
|
|
||||||
/// In other words, this function returns the value (the `T`) of a
|
|
||||||
/// `Result<T, T>`, regardless of whether or not that result is `Ok` or
|
|
||||||
/// `Err`.
|
|
||||||
///
|
|
||||||
/// This can be useful in conjunction with APIs such as
|
|
||||||
/// [`Atomic*::compare_exchange`], or [`slice::binary_search`], but only in
|
|
||||||
/// cases where you don't care if the result was `Ok` or not.
|
|
||||||
///
|
|
||||||
/// [`Atomic*::compare_exchange`]: crate::sync::atomic::AtomicBool::compare_exchange
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// #![feature(result_into_ok_or_err)]
|
|
||||||
/// let ok: Result<u32, u32> = Ok(3);
|
|
||||||
/// let err: Result<u32, u32> = Err(4);
|
|
||||||
///
|
|
||||||
/// assert_eq!(ok.into_ok_or_err(), 3);
|
|
||||||
/// assert_eq!(err.into_ok_or_err(), 4);
|
|
||||||
/// ```
|
|
||||||
#[inline]
|
|
||||||
#[unstable(feature = "result_into_ok_or_err", reason = "newly added", issue = "82223")]
|
|
||||||
pub const fn into_ok_or_err(self) -> T {
|
|
||||||
match self {
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(v) => v,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a separate function to reduce the code size of the methods
|
// This is a separate function to reduce the code size of the methods
|
||||||
#[cfg(not(feature = "panic_immediate_abort"))]
|
#[cfg(not(feature = "panic_immediate_abort"))]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
|
@ -75,7 +75,6 @@
|
|||||||
#![feature(const_pin)]
|
#![feature(const_pin)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(unwrap_infallible)]
|
#![feature(unwrap_infallible)]
|
||||||
#![feature(result_into_ok_or_err)]
|
|
||||||
#![feature(pointer_byte_offsets)]
|
#![feature(pointer_byte_offsets)]
|
||||||
#![feature(portable_simd)]
|
#![feature(portable_simd)]
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
|
@ -95,15 +95,6 @@ fn test_unwrap_or() {
|
|||||||
assert_eq!(ok_err.unwrap_or(50), 50);
|
assert_eq!(ok_err.unwrap_or(50), 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ok_or_err() {
|
|
||||||
let ok: Result<isize, isize> = Ok(100);
|
|
||||||
let err: Result<isize, isize> = Err(200);
|
|
||||||
|
|
||||||
assert_eq!(ok.into_ok_or_err(), 100);
|
|
||||||
assert_eq!(err.into_ok_or_err(), 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unwrap_or_else() {
|
fn test_unwrap_or_else() {
|
||||||
fn handler(msg: &'static str) -> isize {
|
fn handler(msg: &'static str) -> isize {
|
||||||
|
Loading…
Reference in New Issue
Block a user