@@ -632,10 +632,16 @@ impl<T, E> Result<T, E> {
632
632
/// ```
633
633
#[ inline]
634
634
#[ 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
+ {
636
640
match self {
637
641
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 ,
639
645
}
640
646
}
641
647
@@ -657,9 +663,15 @@ impl<T, E> Result<T, E> {
657
663
/// ```
658
664
#[ inline]
659
665
#[ 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
+ {
661
671
match self {
662
- Ok ( _) => None ,
672
+ // FIXME: ~const Drop doesn't quite work right yet
673
+ #[ allow( unused_variables) ]
674
+ Ok ( x) => None ,
663
675
Err ( x) => Some ( x) ,
664
676
}
665
677
}
@@ -1266,10 +1278,18 @@ impl<T, E> Result<T, E> {
1266
1278
/// assert_eq!(x.and(y), Ok("different result type"));
1267
1279
/// ```
1268
1280
#[ inline]
1281
+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
1269
1282
#[ 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
+ {
1271
1289
match self {
1272
- Ok ( _) => res,
1290
+ // FIXME: ~const Drop doesn't quite work right yet
1291
+ #[ allow( unused_variables) ]
1292
+ Ok ( x) => res,
1273
1293
Err ( e) => Err ( e) ,
1274
1294
}
1275
1295
}
@@ -1331,11 +1351,19 @@ impl<T, E> Result<T, E> {
1331
1351
/// assert_eq!(x.or(y), Ok(2));
1332
1352
/// ```
1333
1353
#[ inline]
1354
+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
1334
1355
#[ 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
+ {
1336
1362
match self {
1337
1363
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,
1339
1367
}
1340
1368
}
1341
1369
@@ -1387,11 +1415,18 @@ impl<T, E> Result<T, E> {
1387
1415
/// assert_eq!(x.unwrap_or(default), default);
1388
1416
/// ```
1389
1417
#[ inline]
1418
+ #[ rustc_const_unstable( feature = "const_result_drop" , issue = "92384" ) ]
1390
1419
#[ 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
+ {
1392
1425
match self {
1393
1426
Ok ( t) => t,
1394
- Err ( _) => default,
1427
+ // FIXME: ~const Drop doesn't quite work right yet
1428
+ #[ allow( unused_variables) ]
1429
+ Err ( e) => default,
1395
1430
}
1396
1431
}
1397
1432
0 commit comments