diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-01-06 12:59:46 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-01-11 03:08:40 +0000 |
| commit | a5f42397be001b771945b23b2742b8bc9f9151b2 (patch) | |
| tree | e9d0514e03dc1f7880a27b7b17f98c605e472005 | |
| parent | e6217972644588a3be4fecb85b195f17b0220047 (diff) | |
| download | rust-a5f42397be001b771945b23b2742b8bc9f9151b2.tar.gz rust-a5f42397be001b771945b23b2742b8bc9f9151b2.zip | |
Rename Result::as_deref_ok to as_deref
| -rw-r--r-- | src/libcore/result.rs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs index aa57c7788c6..c657ce33f60 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1136,7 +1136,7 @@ impl<T: Deref, E> Result<T, E> { /// /// Leaves the original `Result` in-place, creating a new one containing a reference to the /// `Ok` type's `Deref::Target` type. - pub fn as_deref_ok(&self) -> Result<&T::Target, &E> { + pub fn as_deref(&self) -> Result<&T::Target, &E> { self.as_ref().map(|t| t.deref()) } } @@ -1153,23 +1153,12 @@ impl<T, E: Deref> Result<T, E> { } #[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")] -impl<T: Deref, E: Deref> Result<T, E> { - /// Converts from `Result<T, E>` (or `&Result<T, E>`) to `Result<&T::Target, &E::Target>`. - /// - /// Leaves the original `Result` in-place, creating a new one containing a reference to both - /// the `Ok` and `Err` types' `Deref::Target` types. - pub fn as_deref(&self) -> Result<&T::Target, &E::Target> { - self.as_ref().map(|t| t.deref()).map_err(|e| e.deref()) - } -} - -#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")] impl<T: DerefMut, E> Result<T, E> { /// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to `Result<&mut T::Target, &mut E>`. /// /// Leaves the original `Result` in-place, creating a new one containing a mutable reference to /// the `Ok` type's `Deref::Target` type. - pub fn as_deref_mut_ok(&mut self) -> Result<&mut T::Target, &mut E> { + pub fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E> { self.as_mut().map(|t| t.deref_mut()) } } @@ -1185,18 +1174,6 @@ impl<T, E: DerefMut> Result<T, E> { } } -#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")] -impl<T: DerefMut, E: DerefMut> Result<T, E> { - /// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to - /// `Result<&mut T::Target, &mut E::Target>`. - /// - /// Leaves the original `Result` in-place, creating a new one containing a mutable reference to - /// both the `Ok` and `Err` types' `Deref::Target` types. - pub fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E::Target> { - self.as_mut().map(|t| t.deref_mut()).map_err(|e| e.deref_mut()) - } -} - impl<T, E> Result<Option<T>, E> { /// Transposes a `Result` of an `Option` into an `Option` of a `Result`. /// |
