@@ -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 |
|
1543 |
+// FIXME: 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 |