Skip to main content

turso_debug_assert

Macro turso_debug_assert 

Source
turso_debug_assert!() { /* proc-macro */ }
Expand description

Drop-in replacement for [debug_assert!] that additionally reports to the Antithesis SDK when compiled with --features antithesis.

Maps to antithesis_sdk::assert_always_or_unreachable!.

§Behavior

  • Without antithesis feature: behaves exactly like [debug_assert!] — panics on failure in debug builds, compiled out in release builds.
  • With antithesis feature: reports the property to Antithesis via assert_always_or_unreachable!. On failure, prints the error to stderr and calls std::process::exit(0) instead of panicking. The clean exit lets Antithesis properly process the property violation. The normal debug_assert! is skipped in this path.

§Parameters

Same as turso_assert!:

  • condition — boolean expression to check.
  • "message" (optional) — human-readable description.
  • { "key": value, ... } (optional) — structured details for Antithesis.

§Usage

turso_debug_assert!(condition);
turso_debug_assert!(condition, "message");
turso_debug_assert!(condition, "message", { "key": value });

§Examples

turso_debug_assert!(value <= PageSize::MAX as usize);
turso_debug_assert!(matches!(self.page_type(), Ok(PageType::TableInterior)));

§When to use

Use turso_debug_assert! for invariant checks that are too expensive for release builds (e.g., scanning a list to verify sorted order).