mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
Rename Result::as_deref_ok to as_deref
This commit is contained in:
parent
e621797264
commit
a5f42397be
@ -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
|
/// Leaves the original `Result` in-place, creating a new one containing a reference to the
|
||||||
/// `Ok` type's `Deref::Target` type.
|
/// `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())
|
self.as_ref().map(|t| t.deref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1152,24 +1152,13 @@ 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")]
|
#[unstable(feature = "inner_deref", reason = "newly added", issue = "50264")]
|
||||||
impl<T: DerefMut, E> Result<T, E> {
|
impl<T: DerefMut, E> Result<T, E> {
|
||||||
/// Converts from `Result<T, E>` (or `&mut Result<T, E>`) to `Result<&mut T::Target, &mut 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
|
/// Leaves the original `Result` in-place, creating a new one containing a mutable reference to
|
||||||
/// the `Ok` type's `Deref::Target` type.
|
/// 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())
|
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> {
|
impl<T, E> Result<Option<T>, E> {
|
||||||
/// Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
/// Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user