Expand description
A “prelude” module providing a collection of useful names, without causing compiler complaints about the ones you don’t use.
Provided names are:
- The core
anyhow::Errortype - The core
anyhow::Resulttype, which isResult<T, anyhow::Error> - The
anyhow!macro to create an Error value from a string-format expression - The
bail!macro:bail!(...)=return Err(anyhow!(...)) - The
ensure!macro:ensure!(cond, err)=if !cond { bail!(err); } - The
atry!macro for annotated question-mark behavior - The
a_ok_or!macro for annotated, fallibale Option unwrapping - Rust’s
std::result::Resulttype aliased as StdResult for convenience
Macros§
- a_ok_or
- “annotated ok_or” — like
Option::ok_or_else()?, but with the ability to add extended context to the error. This yields anAnnotatedMessageas its error type. - anyhow
- Construct an ad-hoc error from a string or existing non-
anyhowerror value. - atry
- “Annotated try” — like
try!, but with the ability to add extended context to the error message. This tries to provide a bit more syntactic sugar than anyhow’swith_context(), and it supports our AnnotatedMessage context type. - bail
- Return early with an error.
- ensure
- Return early with an error if a condition is not satisfied.
Structs§
- Error
- The
Errortype, a wrapper around a dynamic error type.
Enums§
Type Aliases§
- Result
Result<T, Error>