@@ -797,7 +797,8 @@ impl<T> Option<T> {
797797 #[ inline]
798798 #[ must_use]
799799 #[ stable( feature = "option_as_slice" , since = "1.75.0" ) ]
800- pub fn as_slice ( & self ) -> & [ T ] {
800+ #[ rustc_const_unstable( feature = "const_option_ext" , issue = "91930" ) ]
801+ pub const fn as_slice ( & self ) -> & [ T ] {
801802 // SAFETY: When the `Option` is `Some`, we're using the actual pointer
802803 // to the payload, with a length of 1, so this is equivalent to
803804 // `slice::from_ref`, and thus is safe.
@@ -811,7 +812,7 @@ impl<T> Option<T> {
811812 unsafe {
812813 slice:: from_raw_parts (
813814 ( self as * const Self ) . byte_add ( core:: mem:: offset_of!( Self , Some . 0 ) ) . cast ( ) ,
814- usize :: from ( self . is_some ( ) ) ,
815+ self . is_some ( ) as usize ,
815816 )
816817 }
817818 }
@@ -851,7 +852,8 @@ impl<T> Option<T> {
851852 #[ inline]
852853 #[ must_use]
853854 #[ stable( feature = "option_as_slice" , since = "1.75.0" ) ]
854- pub fn as_mut_slice ( & mut self ) -> & mut [ T ] {
855+ #[ rustc_const_unstable( feature = "const_option_ext" , issue = "91930" ) ]
856+ pub const fn as_mut_slice ( & mut self ) -> & mut [ T ] {
855857 // SAFETY: When the `Option` is `Some`, we're using the actual pointer
856858 // to the payload, with a length of 1, so this is equivalent to
857859 // `slice::from_mut`, and thus is safe.
@@ -867,7 +869,7 @@ impl<T> Option<T> {
867869 unsafe {
868870 slice:: from_raw_parts_mut (
869871 ( self as * mut Self ) . byte_add ( core:: mem:: offset_of!( Self , Some . 0 ) ) . cast ( ) ,
870- usize :: from ( self . is_some ( ) ) ,
872+ self . is_some ( ) as usize ,
871873 )
872874 }
873875 }
0 commit comments