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:
bors
2026-05-25 16:51:27 +00:00
2 changed files with 2 additions and 11 deletions
+2 -10
View File
@@ -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>(
-1
View File
@@ -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)]