Closed
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.