pub trait ResultExt<T, E>: Sized {
// Required methods
fn context_with<C: ToTokensError + 'static>(
self,
error: impl FnOnce() -> C,
) -> Result<T, Error>;
fn attachment(self, label: &'static str, msg: impl Display) -> Self
where E: Attachment;
// Provided methods
fn context(self, error: impl ToTokensError + 'static) -> Result<T, Error> { ... }
fn error(self, msg: impl Display) -> Self
where E: Attachment { ... }
fn warning(self, msg: impl Display) -> Self
where E: Attachment { ... }
fn note(self, msg: impl Display) -> Self
where E: Attachment { ... }
fn help(self, msg: impl Display) -> Self
where E: Attachment { ... }
}Expand description
Some utilities on Result<T, impl ToTokensError>
Required Methods§
Sourcefn context_with<C: ToTokensError + 'static>(
self,
error: impl FnOnce() -> C,
) -> Result<T, Error>
fn context_with<C: ToTokensError + 'static>( self, error: impl FnOnce() -> C, ) -> Result<T, Error>
If self is error, attaches another error, closure is only executed if
the Result is Err
Sourcefn attachment(self, label: &'static str, msg: impl Display) -> Selfwhere
E: Attachment,
fn attachment(self, label: &'static str, msg: impl Display) -> Selfwhere
E: Attachment,
If self is error, extend error message
Only works if E implements Attachment which is the case for
ErrorMessage
Provided Methods§
Sourcefn context(self, error: impl ToTokensError + 'static) -> Result<T, Error>
fn context(self, error: impl ToTokensError + 'static) -> Result<T, Error>
If self is error, attaches another error
Sourcefn error(self, msg: impl Display) -> Selfwhere
E: Attachment,
fn error(self, msg: impl Display) -> Selfwhere
E: Attachment,
Attaches a new error message to self reusing the same span
Sourcefn warning(self, msg: impl Display) -> Selfwhere
E: Attachment,
fn warning(self, msg: impl Display) -> Selfwhere
E: Attachment,
Attaches a new warning message to self reusing the same span
Sourcefn note(self, msg: impl Display) -> Selfwhere
E: Attachment,
fn note(self, msg: impl Display) -> Selfwhere
E: Attachment,
Attaches a new note message to self reusing the same span
Sourcefn help(self, msg: impl Display) -> Selfwhere
E: Attachment,
fn help(self, msg: impl Display) -> Selfwhere
E: Attachment,
Attaches a new help message to self reusing the same span
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.