@@ -1535,11 +1535,17 @@ impl<T, E> Result<&T, E> {
1535
1535
/// ```
1536
1536
#[ inline]
1537
1537
#[ stable( feature = "result_copied" , since = "1.59.0" ) ]
1538
- pub fn copied ( self ) -> Result < T , E >
1538
+ #[ rustc_const_unstable( feature = "const_result" , issue = "82814" ) ]
1539
+ pub const fn copied ( self ) -> Result < T , E >
1539
1540
where
1540
1541
T : Copy ,
1541
1542
{
1542
- self . map ( |& t| t)
1543
+ // FIXME(const-hack): this implementation, which sidesteps using `Result::map` since it's not const
1544
+ // ready yet, should be reverted when possible to avoid code repetition
1545
+ match self {
1546
+ Ok ( & v) => Ok ( v) ,
1547
+ Err ( e) => Err ( e) ,
1548
+ }
1543
1549
}
1544
1550
1545
1551
/// Maps a `Result<&T, E>` to a `Result<T, E>` by cloning the contents of the
@@ -1579,11 +1585,17 @@ impl<T, E> Result<&mut T, E> {
1579
1585
/// ```
1580
1586
#[ inline]
1581
1587
#[ stable( feature = "result_copied" , since = "1.59.0" ) ]
1582
- pub fn copied ( self ) -> Result < T , E >
1588
+ #[ rustc_const_unstable( feature = "const_result" , issue = "82814" ) ]
1589
+ pub const fn copied ( self ) -> Result < T , E >
1583
1590
where
1584
1591
T : Copy ,
1585
1592
{
1586
- self . map ( |& mut t| t)
1593
+ // FIXME(const-hack): this implementation, which sidesteps using `Result::map` since it's not const
1594
+ // ready yet, should be reverted when possible to avoid code repetition
1595
+ match self {
1596
+ Ok ( & mut v) => Ok ( v) ,
1597
+ Err ( e) => Err ( e) ,
1598
+ }
1587
1599
}
1588
1600
1589
1601
/// Maps a `Result<&mut T, E>` to a `Result<T, E>` by cloning the contents of the
0 commit comments