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RBTIPUZQ5BNX34D3VD2JAIYLRN6XSAC
W5YRNIBZIMTQLOKIBWBF7CHCIOLKXVHV7Y2AIKMKG7GCQSAVZKBAC
VWTWVVRECX62JABUZYFCTCPWTXXT3DB4635RIAGCKIQMGJ7VXRGAC
UV757IN647TV4DBKTK2QYSGVFPM7W7M6MBU3CDDGIOICNNWK33GQC
FI5C6CUHWX54GBVTIVMOO2E6KS4SMKMAZJULXGGVNST5QFZFHSMAC
GMOFRJTUHSZVX2U7Z7PVQDY45MQJQ7LTUIHCKHTCJJX2P6UH76ZAC
RF4MODRCRWKMUG26O222X3ZY3MLE6X7BYZDWEQRLVUITTWYAGNUAC
Q3TF6DU36OM4M4A72QPN74NRKH7CZBBKFAKLTJRPL5JD3LI5276QC
OXKWHQFHTDDOWX3QDMHDWHCT3HFKWQS7Z7DEL3ILJBA7GNITA4GAC
HO72KYBN3DYN6EC2RQUW4YP3CFBSY4X3ULYLFA2HQ36S5QGTGKIQC
WJ65BKIQTRTLNUGFCDLYFBCJKWFT4Y4FIPEOQOFKDQGAYMJKIMQAC
EVYOBH4FZF227T7L5ZIUHML4Y4ETGDD263I7LH2SXLJ65VKPWHFAC
DAFQ2ZKJ5PUWBADTJ7O2FRVHQNYC7UCHX4IYXYCJQ3PFSBONAV6QC
HSOG2FYBIHDIMTG2YARL57AIHOOSG2P7ZXQTE6ZN7PRNEO22VRQQC
R2FB5PBSU5SCGAQ33AKFG5WJ2T2L7ZDA4LDKTIKRMBGVA2ST5YPQC
WCPISJ4XXCQWQTGDUHPSEI6UFTAJHLAU54CAMOXXSVHQPLAV4DEAC
/// ```
/// # type T = ();
/// #
/// use eyre::{Report, Result};
///
/// fn maybe_get() -> Option<T> {
/// # const IGNORE: &str = stringify! {
/// ...
/// # };
/// # unimplemented!()
/// }
///
/// fn demo() -> Result<()> {
/// let t = maybe_get().wrap_err("there is no T")?;
/// # const IGNORE: &str = stringify! {
/// ...
/// # };
/// # unimplemented!()
/// }
/// ```
impl<T> Report<T, Infallible> for Option<T> {
fn wrap_err<D>(self, msg: D) -> Result<T, ErrReport<DefaultContext>>
where
D: Display + Send + Sync + 'static,
{
self.ok_or_else(|| ErrReport::from_display(msg))
}
fn wrap_err_with<D, F>(self, msg: F) -> Result<T, ErrReport<DefaultContext>>
where
D: Display + Send + Sync + 'static,
F: FnOnce() -> D,
{
self.ok_or_else(|| ErrReport::from_display(msg()))
}
}
pub(crate) fn from_display<M>(message: M) -> Self
where
M: Display + Send + Sync + 'static,
{
use crate::wrapper::DisplayError;
let error: DisplayError<M> = DisplayError(message);
let vtable = &ErrorVTable {
object_drop: object_drop::<DisplayError<M>, C>,
object_ref: object_ref::<DisplayError<M>, C>,
#[cfg(feature = "std")]
object_mut: object_mut::<DisplayError<M>, C>,
object_boxed: object_boxed::<DisplayError<M>, C>,
object_downcast: object_downcast::<M, C>,
object_drop_rest: object_drop_front::<M, C>,
};
// Safety: DisplayError is repr(transparent) so it is okay for the
// vtable to allow casting the DisplayError<M> to M.
unsafe { ErrReport::construct(error, vtable) }
}
/// This is a reasonable return type to use throughout your application but also
/// for `fn main`; if you do, failures will be printed along with any
/// [context][Report] and a backtrace if one was captured.
/// This is a reasonable return type to use throughout your application but also for `fn main`; if
/// you do, failures will be printed along with a backtrace if one was captured.