]> git.lizzy.rs Git - rust.git/commitdiff
Consolidate impl Result<&mut T, E>
authorDavid Tolnay <dtolnay@gmail.com>
Thu, 30 Dec 2021 18:31:26 +0000 (10:31 -0800)
committerDavid Tolnay <dtolnay@gmail.com>
Thu, 30 Dec 2021 18:31:26 +0000 (10:31 -0800)
library/core/src/result.rs

index 29a0be68083c5a241ef201395157614b4772ec8c..f46632e7a8d2030b78f5a9b5986737d98a4a46c4 100644 (file)
@@ -1537,7 +1537,7 @@ pub fn cloned(self) -> 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.
     ///
     /// 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")]
     /// 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)
     }
         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.
     ///
     /// 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")]
     /// 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())
     }
 }
         self.map(|t| t.clone())
     }
 }