rust: macro debug_validate_fail to fail with message

Add a new debug_validate macro that unconditionally panics
with a message. Useful in Rust pattern matching.
pull/5115/head
Jason Ish 5 years ago committed by Victor Julien
parent 4127c5fcc8
commit ca6b70ea1b

@ -30,6 +30,23 @@ macro_rules! debug_validate_bug_on (
};
);
#[cfg(not(feature = "debug-validate"))]
#[macro_export]
macro_rules! debug_validate_fail (
($msg:expr) => {};
);
#[cfg(feature = "debug-validate")]
#[macro_export]
macro_rules! debug_validate_fail (
($msg:expr) => {
// Wrap in a conditional to prevent unreachable code warning in caller.
if true {
panic!($msg);
}
};
);
/// Convert a String to C-compatible string
///
/// This function will consume the provided data and use the underlying bytes to construct a new

Loading…
Cancel
Save