Skip to content

Commit 2c7cfb9

Browse files
author
CDirkx
committed
Stabilize some Result methods as const
Stabilize the following methods of `Result` as const: - `is_ok` - `is_err` - `as_ref` Possible because of stabilization of rust-lang#49146 (Allow if and match in constants).
1 parent 763cf9c commit 2c7cfb9

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
#![feature(const_ptr_offset)]
8888
#![feature(const_ptr_offset_from)]
8989
#![feature(const_raw_ptr_comparison)]
90-
#![feature(const_result)]
9190
#![feature(const_slice_from_raw_parts)]
9291
#![feature(const_slice_ptr_len)]
9392
#![feature(const_size_of_val)]

core/src/result.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<T, E> Result<T, E> {
273273
/// assert_eq!(x.is_ok(), false);
274274
/// ```
275275
#[must_use = "if you intended to assert that this is ok, consider `.unwrap()` instead"]
276-
#[rustc_const_unstable(feature = "const_result", issue = "67520")]
276+
#[rustc_const_stable(feature = "const_result", since = "1.48.0")]
277277
#[inline]
278278
#[stable(feature = "rust1", since = "1.0.0")]
279279
pub const fn is_ok(&self) -> bool {
@@ -294,7 +294,7 @@ impl<T, E> Result<T, E> {
294294
/// assert_eq!(x.is_err(), true);
295295
/// ```
296296
#[must_use = "if you intended to assert that this is err, consider `.unwrap_err()` instead"]
297-
#[rustc_const_unstable(feature = "const_result", issue = "67520")]
297+
#[rustc_const_stable(feature = "const_result", since = "1.48.0")]
298298
#[inline]
299299
#[stable(feature = "rust1", since = "1.0.0")]
300300
pub const fn is_err(&self) -> bool {
@@ -438,7 +438,7 @@ impl<T, E> Result<T, E> {
438438
/// assert_eq!(x.as_ref(), Err(&"Error"));
439439
/// ```
440440
#[inline]
441-
#[rustc_const_unstable(feature = "const_result", issue = "67520")]
441+
#[rustc_const_stable(feature = "const_result", since = "1.48.0")]
442442
#[stable(feature = "rust1", since = "1.0.0")]
443443
pub const fn as_ref(&self) -> Result<&T, &E> {
444444
match *self {

0 commit comments

Comments
 (0)