use crate::Error;
#[cfg_attr(
any(feature = "rust-v1.81", feature = "std"),
doc = r##"
[`prelude::Stashable`]: crate::prelude::Stashable
"##
)]
#[cfg_attr(
not(any(feature = "rust-v1.81", feature = "std")),
doc = r##"
[`prelude::Stashable`]: crate::surrogate_error_trait::prelude::Stashable
"##
)]
pub trait OrWrap<T, E> {
#[cfg_attr(
any(feature = "rust-v1.81", feature = "std"),
doc = r##"
[`prelude::Stashable`]: crate::prelude::Stashable
"##
)]
#[cfg_attr(
not(any(feature = "rust-v1.81", feature = "std")),
doc = r##"
[`prelude::Stashable`]: crate::surrogate_error_trait::prelude::Stashable
"##
)]
fn or_wrap<I>(self) -> Result<T, Error<I>>
where
E: Into<I>;
}
impl<T, E> OrWrap<T, E> for Result<T, E> {
#[track_caller]
fn or_wrap<I>(self) -> Result<T, Error<I>>
where
E: Into<I>,
{
match self {
Ok(t) => Ok(t),
Err(inner) => Err(Error::wrap(inner)),
}
}
}