Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make these methods public
  • Loading branch information
ksqsf committed Jul 31, 2019
commit 5a36b0dba1d7a350bba04b1abf256f057b3d1079
16 changes: 8 additions & 8 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
fn copied(self) -> Result<T, E> {
pub fn copied(self) -> Result<T, E> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut tells me that this should be called copied_ok so that there can be a copied that will copy both sides in one go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure about the usefulness. From my experience, I usually only need copied_ok and cloned_ok. But indeed having copied, copied_ok, and copied_err is more consistent. I've added them in the update.

self.map(|&t| t)
}
}
Expand All @@ -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")]
fn copied(self) -> Result<T, E> {
pub fn copied(self) -> Result<T, E> {
self.map(|&mut t| t)
}
}
Expand All @@ -875,7 +875,7 @@ impl<T, E: Copy> Result<T, &E> {
/// assert_eq!(copied, Err(12));
/// ```
#[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
fn copied_err(self) -> Result<T, E> {
pub fn copied_err(self) -> Result<T, E> {
self.map_err(|&e| e)
}
}
Expand All @@ -895,7 +895,7 @@ impl<T, E: Copy> Result<T, &mut E> {
/// assert_eq!(cloned, Err(12));
/// ```
#[unstable(feature = "result_copied", reason = "newly added", issue = "63168")]
fn copied_err(self) -> Result<T, E> {
pub fn copied_err(self) -> Result<T, E> {
self.map_err(|&mut e| e)
}
}
Expand All @@ -915,7 +915,7 @@ impl<T: Clone, E> Result<&T, E> {
/// assert_eq!(cloned, Ok(12));
/// ```
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
fn cloned(self) -> Result<T, E> {
pub fn cloned(self) -> Result<T, E> {
self.map(|t| t.clone())
}
}
Expand All @@ -935,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")]
fn cloned(self) -> Result<T, E> {
pub fn cloned(self) -> Result<T, E> {
self.map(|t| t.clone())
}
}
Expand All @@ -955,7 +955,7 @@ impl<T, E: Clone> Result<T, &E> {
/// assert_eq!(cloned, Err(12));
/// ```
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
fn cloned_err(self) -> Result<T, E> {
pub fn cloned_err(self) -> Result<T, E> {
self.map_err(|e| e.clone())
}
}
Expand All @@ -975,7 +975,7 @@ impl<T, E: Clone> Result<T, &mut E> {
/// assert_eq!(cloned, Err(12));
/// ```
#[unstable(feature = "result_cloned", reason = "newly added", issue = "63168")]
fn cloned_err(self) -> Result<T, E> {
pub fn cloned_err(self) -> Result<T, E> {
self.map_err(|e| e.clone())
}
}
Expand Down