@@ -179,8 +179,9 @@ impl<T> Option<T> {
179
179
/// [`Some`]: #variant.Some
180
180
#[ must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead" ]
181
181
#[ inline]
182
+ #[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
182
183
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
183
- pub fn is_some ( & self ) -> bool {
184
+ pub const fn is_some ( & self ) -> bool {
184
185
matches ! ( * self , Some ( _) )
185
186
}
186
187
@@ -200,8 +201,9 @@ impl<T> Option<T> {
200
201
#[ must_use = "if you intended to assert that this doesn't have a value, consider \
201
202
`.and_then(|| panic!(\" `Option` had a value when expected `None`\" ))` instead"]
202
203
#[ inline]
204
+ #[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
203
205
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
204
- pub fn is_none ( & self ) -> bool {
206
+ pub const fn is_none ( & self ) -> bool {
205
207
!self . is_some ( )
206
208
}
207
209
@@ -259,8 +261,9 @@ impl<T> Option<T> {
259
261
/// println!("still can print text: {:?}", text);
260
262
/// ```
261
263
#[ inline]
264
+ #[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
262
265
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
263
- pub fn as_ref ( & self ) -> Option < & T > {
266
+ pub const fn as_ref ( & self ) -> Option < & T > {
264
267
match * self {
265
268
Some ( ref x) => Some ( x) ,
266
269
None => None ,
@@ -580,8 +583,9 @@ impl<T> Option<T> {
580
583
/// assert_eq!(x.iter().next(), None);
581
584
/// ```
582
585
#[ inline]
586
+ #[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
583
587
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
584
- pub fn iter ( & self ) -> Iter < ' _ , T > {
588
+ pub const fn iter ( & self ) -> Iter < ' _ , T > {
585
589
Iter { inner : Item { opt : self . as_ref ( ) } }
586
590
}
587
591
0 commit comments