use crate::clone::TryClone;
use crate::error::Error;
pub trait OptionExt<T> {
#[must_use = "`self` will be dropped if the result is not used"]
fn try_cloned(self) -> Result<Option<T>, Error>;
}
impl<T> OptionExt<T> for Option<&T>
where
T: TryClone,
{
fn try_cloned(self) -> Result<Option<T>, Error> {
Ok(match self {
Some(value) => Some(value.try_clone()?),
None => None,
})
}
}