Skip to content

Commit db109c6

Browse files
author
CDirkx
committed
Stabilize some Option methods as const
Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` Possible because of stabilization of #49146 (Allow if and match in constants).
1 parent 85fbf49 commit db109c6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

library/core/src/option.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<T> Option<T> {
175175
/// ```
176176
#[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"]
177177
#[inline]
178-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
178+
#[rustc_const_stable(feature = "const_option", since = "1.48.0")]
179179
#[stable(feature = "rust1", since = "1.0.0")]
180180
pub const fn is_some(&self) -> bool {
181181
matches!(*self, Some(_))
@@ -195,7 +195,7 @@ impl<T> Option<T> {
195195
#[must_use = "if you intended to assert that this doesn't have a value, consider \
196196
`.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"]
197197
#[inline]
198-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
198+
#[rustc_const_stable(feature = "const_option", since = "1.48.0")]
199199
#[stable(feature = "rust1", since = "1.0.0")]
200200
pub const fn is_none(&self) -> bool {
201201
!self.is_some()
@@ -254,7 +254,7 @@ impl<T> Option<T> {
254254
/// println!("still can print text: {:?}", text);
255255
/// ```
256256
#[inline]
257-
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
257+
#[rustc_const_stable(feature = "const_option", since = "1.48.0")]
258258
#[stable(feature = "rust1", since = "1.0.0")]
259259
pub const fn as_ref(&self) -> Option<&T> {
260260
match *self {

src/test/ui/consts/const-option.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// run-pass
22

3-
#![feature(const_option)]
4-
53
const X: Option<i32> = Some(32);
64
const Y: Option<&i32> = X.as_ref();
75

0 commit comments

Comments
 (0)