Revert "cloned/copied"

This reverts commit 6c13081762.
This commit is contained in:
ksqsf 2019-08-01 13:38:23 +08:00
parent 6c13081762
commit 4b2f598986

View file

@ -835,7 +835,7 @@ impl<T: Copy, E> Result<&T, E> {
/// assert_eq!(copied, Ok(12));
/// ```
#[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
pub fn copied_ok(self) -> Result<T, E> {
pub fn copied(self) -> Result<T, E> {
self.map(|&t| t)
}
}
@ -855,7 +855,7 @@ impl<T: Copy, E> Result<&mut T, E> {
/// assert_eq!(copied, Ok(12));
/// ```
#[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
pub fn copied_ok(self) -> Result<T, E> {
pub fn copied(self) -> Result<T, E> {
self.map(|&mut t| t)
}
}
@ -900,74 +900,6 @@ impl<T, E: Copy> Result<T, &mut E> {
}
}
impl<T: Copy, E: Copy> Result<&T, &E> {
/// Maps a `Result<&T, &E>` to a `Result<T, E>` 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<T, E> {
self.copied_ok().copied_err()
}
}
impl<T: Copy, E: Copy> Result<&mut T, &E> {
/// Maps a `Result<&mut T, &E>` to a `Result<T, E>` 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<T, E> {
self.copied_ok().copied_err()
}
}
impl<T: Copy, E: Copy> Result<&T, &mut E> {
/// Maps a `Result<&T, &mut E>` to a `Result<T, E>` 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<T, E> {
self.copied_ok().copied_err()
}
}
impl<T: Copy, E: Copy> Result<&mut T, &mut E> {
/// Maps a `Result<&mut T, &mut E>` to a `Result<T, E>` 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<T, E> {
self.copied_ok().copied_err()
}
}
impl<T: Clone, E> Result<&T, E> {
/// Maps a `Result<&T, E>` to a `Result<T, E>` by cloning the contents of the
/// `Ok` part.
@ -983,7 +915,7 @@ impl<T: Clone, E> Result<&T, E> {
/// assert_eq!(cloned, Ok(12));
/// ```
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
pub fn cloned_ok(self) -> Result<T, E> {
pub fn cloned(self) -> Result<T, E> {
self.map(|t| t.clone())
}
}
@ -1003,7 +935,7 @@ impl<T: Clone, E> Result<&mut T, E> {
/// assert_eq!(cloned, Ok(12));
/// ```
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
pub fn cloned_ok(self) -> Result<T, E> {
pub fn cloned(self) -> Result<T, E> {
self.map(|t| t.clone())
}
}
@ -1048,74 +980,6 @@ impl<T, E: Clone> Result<T, &mut E> {
}
}
impl<T: Clone, E: Clone> Result<&T, &E> {
/// Maps a `Result<&T, &E>` to a `Result<T, E>` 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<T, E> {
self.cloned_ok().cloned_err()
}
}
impl<T: Clone, E: Clone> Result<&mut T, &E> {
/// Maps a `Result<&mut T, &E>` to a `Result<T, E>` 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<T, E> {
self.cloned_ok().cloned_err()
}
}
impl<T: Clone, E: Clone> Result<&T, &mut E> {
/// Maps a `Result<&T, &mut E>` to a `Result<T, E>` 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<T, E> {
self.cloned_ok().cloned_err()
}
}
impl<T: Clone, E: Clone> Result<&mut T, &mut E> {
/// Maps a `Result<&mut T, &mut E>` to a `Result<T, E>` 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<T, E> {
self.cloned_ok().cloned_err()
}
}
impl<T, E: fmt::Debug> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Ok`].
///