Expand description
Macros for testing conditions without panicking. The expect_*
family of macros cause an early
return of an anyhow::Error
if the expected condition is not met.
Macros§
- Expects that the given condition evaluates to
true
; otherwise returns early. - Expects that the given container (e.g.,
Vec
) contains the element or given string contains the substring; otherwise returns early. - Expects that the given container (e.g.,
Vec
) is empty; otherwise returns early. - Expects that a == b; otherwise returns early.
- Expects that the given
Result
isErr
and returns the unwrapped error; otherwise returns early. - Expects that a != b; otherwise returns early.
- Expects that the given
Option
isNone
; otherwise returns early. - Expects that the given container (e.g.,
Vec
) contains at least one element or given string has non-zero length; otherwise returns early. - Expects that the given
Result
isOk
and returns its unwrapped contents; otherwise returns early. - Expects that the given
Option
isSome
and returns its unwrapped contents; otherwise returns early. - Expects that
a
isSome
and its contents are equal tob
.