chaud_hot/util/assert.rs
1//! Assertions that return an error instead of panicking.
2
3macro_rules! err_assert {
4 ($cond:expr) => {{
5 let caller = core::panic::Location::caller();
6
7 anyhow::ensure!(
8 $cond,
9 "assertion failed: `{}` ({}:{})",
10 stringify!($cond),
11 caller.file(),
12 caller.line(),
13 )
14 }};
15}
16pub(crate) use err_assert;
17
18macro_rules! err_unreachable {
19 () => {{
20 let caller = core::panic::Location::caller();
21
22 anyhow::bail!("unreachable ({}:{})", caller.file(), caller.line())
23 }};
24}
25pub(crate) use err_unreachable;