blob: da17a68fc68f03809d40ccd9fcb4ba6864f0841e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/// Binds the given expression to the given pattern, or else executes
/// `debug_assert!(false);` with a helpful panic message and returns.
macro_rules! assume {
($pattern:pat, $value:expr) => {
// The expression might change each time it's evaluated, so we
// have to bind it so that we can reuse it in the panic message.
let _value = $value;
let $pattern = _value else {
debug_assert!(
false,
"assertion `left matches right` failed:
left: {}
right: {:?}",
stringify!($pattern),
_value
);
return;
};
};
}
pub(crate) use assume;
|