Skip to content

Commit b7a0ab1

Browse files
committed
Consolidate impl Result<&mut T, E>
1 parent e63e268 commit b7a0ab1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

library/core/src/result.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ impl<T, E> Result<&T, E> {
15371537
}
15381538
}
15391539

1540-
impl<T: Copy, E> Result<&mut T, E> {
1540+
impl<T, E> Result<&mut T, E> {
15411541
/// Maps a `Result<&mut T, E>` to a `Result<T, E>` by copying the contents of the
15421542
/// `Ok` part.
15431543
///
@@ -1552,12 +1552,13 @@ impl<T: Copy, E> Result<&mut T, E> {
15521552
/// assert_eq!(copied, Ok(12));
15531553
/// ```
15541554
#[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
1555-
pub fn copied(self) -> Result<T, E> {
1555+
pub fn copied(self) -> Result<T, E>
1556+
where
1557+
T: Copy,
1558+
{
15561559
self.map(|&mut t| t)
15571560
}
1558-
}
15591561

1560-
impl<T: Clone, E> Result<&mut T, E> {
15611562
/// Maps a `Result<&mut T, E>` to a `Result<T, E>` by cloning the contents of the
15621563
/// `Ok` part.
15631564
///
@@ -1572,7 +1573,10 @@ impl<T: Clone, E> Result<&mut T, E> {
15721573
/// assert_eq!(cloned, Ok(12));
15731574
/// ```
15741575
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
1575-
pub fn cloned(self) -> Result<T, E> {
1576+
pub fn cloned(self) -> Result<T, E>
1577+
where
1578+
T: Clone,
1579+
{
15761580
self.map(|t| t.clone())
15771581
}
15781582
}

0 commit comments

Comments
 (0)