From 4b2f598986e135f0eb070a9be87a5a963e8ff3d4 Mon Sep 17 00:00:00 2001 From: ksqsf Date: Thu, 1 Aug 2019 13:38:23 +0800 Subject: [PATCH] Revert "cloned/copied" This reverts commit 6c130817623426697d8ebdf5d505487bd11ee2f6. --- src/libcore/result.rs | 144 ++---------------------------------------- 1 file changed, 4 insertions(+), 140 deletions(-) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 0aa8fcb69b9c..77cb447b9546 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -835,7 +835,7 @@ impl Result<&T, E> { /// assert_eq!(copied, Ok(12)); /// ``` #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied_ok(self) -> Result { + pub fn copied(self) -> Result { self.map(|&t| t) } } @@ -855,7 +855,7 @@ impl Result<&mut T, E> { /// assert_eq!(copied, Ok(12)); /// ``` #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied_ok(self) -> Result { + pub fn copied(self) -> Result { self.map(|&mut t| t) } } @@ -900,74 +900,6 @@ impl Result { } } -impl Result<&T, &E> { - /// Maps a `Result<&T, &E>` to a `Result` by copying the - /// contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_copied)] - /// assert_eq!(Err(&1), Err(1)); - /// assert_eq!(Ok(&42), Ok(42)); - /// ``` - #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied(self) -> Result { - self.copied_ok().copied_err() - } -} - -impl Result<&mut T, &E> { - /// Maps a `Result<&mut T, &E>` to a `Result` by copying the - /// contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_copied)] - /// assert_eq!(Err(&1), Err(1)); - /// assert_eq!(Ok(&mut 42), Ok(42)); - /// ``` - #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied(self) -> Result { - self.copied_ok().copied_err() - } -} - -impl Result<&T, &mut E> { - /// Maps a `Result<&T, &mut E>` to a `Result` by copying the - /// contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_copied)] - /// assert_eq!(Err(&mut 1), Err(1)); - /// assert_eq!(Ok(&42), Ok(42)); - /// ``` - #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied(self) -> Result { - self.copied_ok().copied_err() - } -} - -impl Result<&mut T, &mut E> { - /// Maps a `Result<&mut T, &mut E>` to a `Result` by copying - /// the contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_copied)] - /// assert_eq!(Err(&mut 1), Err(1)); - /// assert_eq!(Ok(&mut 42), Ok(42)); - /// ``` - #[unstable(feature = "result_copied", reason = "newly added", issue = "63168")] - pub fn copied(self) -> Result { - self.copied_ok().copied_err() - } -} - impl Result<&T, E> { /// Maps a `Result<&T, E>` to a `Result` by cloning the contents of the /// `Ok` part. @@ -983,7 +915,7 @@ impl Result<&T, E> { /// assert_eq!(cloned, Ok(12)); /// ``` #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned_ok(self) -> Result { + pub fn cloned(self) -> Result { self.map(|t| t.clone()) } } @@ -1003,7 +935,7 @@ impl Result<&mut T, E> { /// assert_eq!(cloned, Ok(12)); /// ``` #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned_ok(self) -> Result { + pub fn cloned(self) -> Result { self.map(|t| t.clone()) } } @@ -1048,74 +980,6 @@ impl Result { } } -impl Result<&T, &E> { - /// Maps a `Result<&T, &E>` to a `Result` by cloning the contents of the - /// result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_cloned)] - /// assert_eq!(Err(&1).cloned(), Err(1)); - /// assert_eq!(Ok(&42).cloned(), Ok(42)); - /// ``` - #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned(self) -> Result { - self.cloned_ok().cloned_err() - } -} - -impl Result<&mut T, &E> { - /// Maps a `Result<&mut T, &E>` to a `Result` by cloning the - /// contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_cloned)] - /// assert_eq!(Err(&1).cloned(), Err(1)); - /// assert_eq!(Ok(&mut 42).cloned(), Ok(42)); - /// ``` - #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned(self) -> Result { - self.cloned_ok().cloned_err() - } -} - -impl Result<&T, &mut E> { - /// Maps a `Result<&T, &mut E>` to a `Result` by cloning the - /// contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_cloned)] - /// assert_eq!(Err(&mut 1).cloned(), Err(1)); - /// assert_eq!(Ok(&42).cloned(), Ok(42)); - /// ``` - #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned(self) -> Result { - self.cloned_ok().cloned_err() - } -} - -impl Result<&mut T, &mut E> { - /// Maps a `Result<&mut T, &mut E>` to a `Result` by cloning - /// the contents of the result. - /// - /// # Examples - /// - /// ``` - /// #![feature(result_cloned)] - /// assert_eq!(Err(&mut 1).cloned(), Err(1)); - /// assert_eq!(Ok(&mut 42).cloned(), Ok(42)); - /// ``` - #[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")] - pub fn cloned(self) -> Result { - self.cloned_ok().cloned_err() - } -} - impl Result { /// Unwraps a result, yielding the content of an [`Ok`]. ///