Crate expecting

Source
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ยง

expect
Expects that the given condition evaluates to true; otherwise returns early.
expect_contains
Expects that the given container (e.g., Vec) contains the element or given string contains the substring; otherwise returns early.
expect_empty
Expects that the given container (e.g., Vec) is empty; otherwise returns early.
expect_eq
Expects that a == b; otherwise returns early.
expect_err
Expects that the given Result is Err and returns the unwrapped error; otherwise returns early.
expect_ne
Expects that a != b; otherwise returns early.
expect_none
Expects that the given Option is None; otherwise returns early.
expect_not_empty
Expects that the given container (e.g., Vec) contains at least one element or given string has non-zero length; otherwise returns early.
expect_ok
Expects that the given Result is Ok and returns its unwrapped contents; otherwise returns early.
expect_some
Expects that the given Option is Some and returns its unwrapped contents; otherwise returns early.
expect_some_eq
Expects that a is Some and its contents are equal to b.