make Result::copied unstably const
This commit is contained in:
parent
009e73825a
commit
03e0c8edb2
1 changed files with 8 additions and 2 deletions
|
@ -1535,11 +1535,17 @@ impl<T, E> Result<&T, E> {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "result_copied", since = "1.59.0")]
|
||||
pub fn copied(self) -> Result<T, E>
|
||||
#[rustc_const_unstable(feature = "const_result", issue = "82814")]
|
||||
pub const fn copied(self) -> Result<T, E>
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
self.map(|&t| t)
|
||||
// FIXME: this implementation, which sidesteps using `Result::map` since it's not const
|
||||
// ready yet, should be reverted when possible to avoid code repetition
|
||||
match self {
|
||||
Ok(&v) => Ok(v),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a `Result<&T, E>` to a `Result<T, E>` by cloning the contents of the
|
||||
|
|
Loading…
Add table
Reference in a new issue