[−][src]Crate bail_out
This library is inspired in the ensure
and bail
macros from anyhow
. The difference is that it is not tied to anyhow's types.
Many libraries have their own error types and using the anyhow's ensure
macro doesn't work because it returns an anyhow error. This library intends to work with any type.
This library also provides the assure
macro, that does the same but evaluates to a Result
instead of returning. This is useful for using inside try
blocks.
Macros
assure | Ensures the condition is met. This evaluates to a |
assure_not | Ensures the condition is not met. This evaluates to a |
assure_not_or | Ensures the condition is not met or returns the value. This evaluates to a |
assure_or | Ensures the condition is met or returns the value. This evaluates to a |
bail | Return early with an error.
This macro is equivalent to |
ensure | Return early with an error if the condition is false. This ensures the condition is met.
This macro is equivalent to |
ensure_not | Return early with an error if the condition is true. This ensures the condition is not met.
This macro is equivalent to |