@@ -632,10 +632,16 @@ impl<T, E> Result<T, E> {
632632 /// ```
633633 #[ inline]
634634 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
635- pub fn ok ( self ) -> Option < T > {
635+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
636+ pub const fn ok ( self ) -> Option < T >
637+ where
638+ E : ~const Drop ,
639+ {
636640 match self {
637641 Ok ( x) => Some ( x) ,
638- Err ( _) => None ,
642+ // FIXME: ~const Drop doesn't quite work right yet
643+ #[ allow( unused_variables) ]
644+ Err ( x) => None ,
639645 }
640646 }
641647
@@ -657,9 +663,15 @@ impl<T, E> Result<T, E> {
657663 /// ```
658664 #[ inline]
659665 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
660- pub fn err ( self ) -> Option < E > {
666+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
667+ pub const fn err ( self ) -> Option < E >
668+ where
669+ T : ~const Drop ,
670+ {
661671 match self {
662- Ok ( _) => None ,
672+ // FIXME: ~const Drop doesn't quite work right yet
673+ #[ allow( unused_variables) ]
674+ Ok ( x) => None ,
663675 Err ( x) => Some ( x) ,
664676 }
665677 }
@@ -1266,10 +1278,18 @@ impl<T, E> Result<T, E> {
12661278 /// assert_eq!(x.and(y), Ok("different result type"));
12671279 /// ```
12681280 #[ inline]
1281+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
12691282 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1270- pub fn and < U > ( self , res : Result < U , E > ) -> Result < U , E > {
1283+ pub const fn and < U > ( self , res : Result < U , E > ) -> Result < U , E >
1284+ where
1285+ T : ~const Drop ,
1286+ U : ~const Drop ,
1287+ E : ~const Drop ,
1288+ {
12711289 match self {
1272- Ok ( _) => res,
1290+ // FIXME: ~const Drop doesn't quite work right yet
1291+ #[ allow( unused_variables) ]
1292+ Ok ( x) => res,
12731293 Err ( e) => Err ( e) ,
12741294 }
12751295 }
@@ -1343,11 +1363,19 @@ impl<T, E> Result<T, E> {
13431363 /// assert_eq!(x.or(y), Ok(2));
13441364 /// ```
13451365 #[ inline]
1366+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
13461367 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1347- pub fn or < F > ( self , res : Result < T , F > ) -> Result < T , F > {
1368+ pub const fn or < F > ( self , res : Result < T , F > ) -> Result < T , F >
1369+ where
1370+ T : ~const Drop ,
1371+ E : ~const Drop ,
1372+ F : ~const Drop ,
1373+ {
13481374 match self {
13491375 Ok ( v) => Ok ( v) ,
1350- Err ( _) => res,
1376+ // FIXME: ~const Drop doesn't quite work right yet
1377+ #[ allow( unused_variables) ]
1378+ Err ( e) => res,
13511379 }
13521380 }
13531381
@@ -1399,11 +1427,18 @@ impl<T, E> Result<T, E> {
13991427 /// assert_eq!(x.unwrap_or(default), default);
14001428 /// ```
14011429 #[ inline]
1430+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
14021431 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1403- pub fn unwrap_or ( self , default : T ) -> T {
1432+ pub const fn unwrap_or ( self , default : T ) -> T
1433+ where
1434+ T : ~const Drop ,
1435+ E : ~const Drop ,
1436+ {
14041437 match self {
14051438 Ok ( t) => t,
1406- Err ( _) => default,
1439+ // FIXME: ~const Drop doesn't quite work right yet
1440+ #[ allow( unused_variables) ]
1441+ Err ( e) => default,
14071442 }
14081443 }
14091444
0 commit comments