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§

  • 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 is Err and returns the unwrapped error; otherwise returns early.
  • Expects that a != b; otherwise returns early.
  • Expects that the given Option is None; 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 is Ok and returns its unwrapped contents; otherwise returns early.
  • Expects that the given Option is Some and returns its unwrapped contents; otherwise returns early.
  • Expects that a is Some and its contents are equal to b.