From b7a0ab18f6b506b73cda720553a5710e7170fc7c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 30 Dec 2021 10:31:26 -0800 Subject: [PATCH] Consolidate impl Result<&mut T, E> --- library/core/src/result.rs | 14 +++++++++----- 1 file 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 @@ pub fn cloned(self) -> Result } } -impl Result<&mut T, E> { +impl Result<&mut T, E> { /// Maps a `Result<&mut T, E>` to a `Result` by copying the contents of the /// `Ok` part. /// @@ -1552,12 +1552,13 @@ impl Result<&mut T, E> { /// assert_eq!(copied, Ok(12)); /// ``` #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied(self) -> Result { + pub fn copied(self) -> Result + where + T: Copy, + { self.map(|&mut t| t) } -} -impl Result<&mut T, E> { /// Maps a `Result<&mut T, E>` to a `Result` by cloning the contents of the /// `Ok` part. /// @@ -1572,7 +1573,10 @@ impl Result<&mut T, E> { /// assert_eq!(cloned, Ok(12)); /// ``` #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned(self) -> Result { + pub fn cloned(self) -> Result + where + T: Clone, + { self.map(|t| t.clone()) } } -- 2.44.0