about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2021-12-30 10:31:26 -0800
committerDavid Tolnay <dtolnay@gmail.com>2021-12-30 10:31:26 -0800
commitb7a0ab18f6b506b73cda720553a5710e7170fc7c (patch)
tree09503a2ec75a192a0b450cce9982a9bdfff4c7ab
parente63e2680dadeb87c9fea78c431e628cf7ed461a6 (diff)
downloadrust-b7a0ab18f6b506b73cda720553a5710e7170fc7c.tar.gz
rust-b7a0ab18f6b506b73cda720553a5710e7170fc7c.zip
Consolidate impl Result<&mut T, E>
-rw-r--r--library/core/src/result.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 29a0be68083..f46632e7a8d 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -1537,7 +1537,7 @@ impl<T, E> Result<&T, E> {
     }
 }
 
-impl<T: Copy, E> Result<&mut T, E> {
+impl<T, E> Result<&mut T, E> {
     /// Maps a `Result<&mut T, E>` to a `Result<T, E>` by copying the contents of the
     /// `Ok` part.
     ///
@@ -1552,12 +1552,13 @@ impl<T: Copy, E> Result<&mut T, E> {
     /// assert_eq!(copied, Ok(12));
     /// ```
     #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
-    pub fn copied(self) -> Result<T, E> {
+    pub fn copied(self) -> Result<T, E>
+    where
+        T: Copy,
+    {
         self.map(|&mut t| t)
     }
-}
 
-impl<T: Clone, E> Result<&mut T, E> {
     /// Maps a `Result<&mut T, E>` to a `Result<T, E>` by cloning the contents of the
     /// `Ok` part.
     ///
@@ -1572,7 +1573,10 @@ impl<T: Clone, E> Result<&mut T, E> {
     /// assert_eq!(cloned, Ok(12));
     /// ```
     #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
-    pub fn cloned(self) -> Result<T, E> {
+    pub fn cloned(self) -> Result<T, E>
+    where
+        T: Clone,
+    {
         self.map(|t| t.clone())
     }
 }