Skip to content

Commit 295946c

Browse files
committed
Option, Result: put the &mut variants of 'copied' under the same feature as the '&' variants
1 parent 0dc4621 commit 295946c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/src/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ impl<T> Option<&mut T> {
19421942
/// ```
19431943
#[must_use = "`self` will be dropped if the result is not used"]
19441944
#[stable(feature = "copied", since = "1.35.0")]
1945-
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
1945+
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
19461946
pub const fn copied(self) -> Option<T>
19471947
where
19481948
T: Copy,

core/src/result.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1585,11 +1585,17 @@ impl<T, E> Result<&mut T, E> {
15851585
/// ```
15861586
#[inline]
15871587
#[stable(feature = "result_copied", since = "1.59.0")]
1588-
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>
15891590
where
15901591
T: Copy,
15911592
{
1592-
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+
}
15931599
}
15941600

15951601
/// Maps a `Result<&mut T, E>` to a `Result<T, E>` by cloning the contents of the

0 commit comments

Comments
 (0)