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
Object Safety§
This trait is not object safe.