mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
Auto merge of #156594 - LimpSquid:stabilize-bool-to-result, r=SimonSapin
Stabilize bool_to_result Closes https://github.com/rust-lang/rust/issues/142748
This commit is contained in:
@@ -78,15 +78,11 @@ pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) ->
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(bool_to_result)]
|
||||
///
|
||||
/// assert_eq!(false.ok_or(0), Err(0));
|
||||
/// assert_eq!(true.ok_or(0), Ok(()));
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(bool_to_result)]
|
||||
///
|
||||
/// let mut a = 0;
|
||||
/// let mut function_with_side_effects = || { a += 1; };
|
||||
///
|
||||
@@ -97,7 +93,7 @@ pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) ->
|
||||
/// // evaluated eagerly.
|
||||
/// assert_eq!(a, 2);
|
||||
/// ```
|
||||
#[unstable(feature = "bool_to_result", issue = "142748")]
|
||||
#[stable(feature = "bool_to_result", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_bool", issue = "151531")]
|
||||
#[inline]
|
||||
pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E> {
|
||||
@@ -110,15 +106,11 @@ pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(bool_to_result)]
|
||||
///
|
||||
/// assert_eq!(false.ok_or_else(|| 0), Err(0));
|
||||
/// assert_eq!(true.ok_or_else(|| 0), Ok(()));
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(bool_to_result)]
|
||||
///
|
||||
/// let mut a = 0;
|
||||
///
|
||||
/// assert!(true.ok_or_else(|| { a += 1; }).is_ok());
|
||||
@@ -128,7 +120,7 @@ pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E> {
|
||||
/// // `ok_or_else`.
|
||||
/// assert_eq!(a, 1);
|
||||
/// ```
|
||||
#[unstable(feature = "bool_to_result", issue = "142748")]
|
||||
#[stable(feature = "bool_to_result", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_bool", issue = "151531")]
|
||||
#[inline]
|
||||
pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>(
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#![feature(ascii_char_variants)]
|
||||
#![feature(async_iter_from_iter)]
|
||||
#![feature(async_iterator)]
|
||||
#![feature(bool_to_result)]
|
||||
#![feature(borrowed_buf_init)]
|
||||
#![feature(bstr)]
|
||||
#![feature(cfg_target_has_reliable_f16_f128)]
|
||||
|
||||
Reference in New Issue
Block a user