-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
It caught me off-guard that there isn't a .cloned()
method for Result<&T, E>
, yet there is one for Option<&T>
.
I don't think this is a big enough feature to have a whole RFC for, even though I can do that if necessary, but it would be nice to have a .cloned()
method like this:
impl<'a, T, E> Result<&'a T, E>
where
T: Clone,
{
#[inline]
pub fn cloned(self) -> Result<T, E> {
self.map(Clone::clone)
}
}
and the equivalent mutable reference version.
However, if there is a reason why this is not already in place, I can understand. It simply feels a little awkward having to manually map Clone::clone
in otherwise idiomatic code.
jesskfullwood
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.