@@ -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 }
@@ -1331,11 +1351,19 @@ impl<T, E> Result<T, E> {
13311351 /// assert_eq!(x.or(y), Ok(2));
13321352 /// ```
13331353 #[ inline]
1354+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
13341355 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1335- pub fn or < F > ( self , res : Result < T , F > ) -> Result < T , F > {
1356+ pub const fn or < F > ( self , res : Result < T , F > ) -> Result < T , F >
1357+ where
1358+ T : ~const Drop ,
1359+ E : ~const Drop ,
1360+ F : ~const Drop ,
1361+ {
13361362 match self {
13371363 Ok ( v) => Ok ( v) ,
1338- Err ( _) => res,
1364+ // FIXME: ~const Drop doesn't quite work right yet
1365+ #[ allow( unused_variables) ]
1366+ Err ( e) => res,
13391367 }
13401368 }
13411369
@@ -1387,11 +1415,18 @@ impl<T, E> Result<T, E> {
13871415 /// assert_eq!(x.unwrap_or(default), default);
13881416 /// ```
13891417 #[ inline]
1418+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
13901419 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1391- pub fn unwrap_or ( self , default : T ) -> T {
1420+ pub const fn unwrap_or ( self , default : T ) -> T
1421+ where
1422+ T : ~const Drop ,
1423+ E : ~const Drop ,
1424+ {
13921425 match self {
13931426 Ok ( t) => t,
1394- Err ( _) => default,
1427+ // FIXME: ~const Drop doesn't quite work right yet
1428+ #[ allow( unused_variables) ]
1429+ Err ( e) => default,
13951430 }
13961431 }
13971432
0 commit comments