#![expect(clippy::arbitrary_source_item_ordering, reason = "macro used")]
macro_rules! safe_expect {
($code:expr, $reason:expr) => {
$code.expect(&format!(
"
This is not meant to happen.
Please report this problem at https://github.com/t-webber/html-parser/issues/new.
Please include the code snippet that created this error and the reason displayed below.
Thank you for signalling this issue!
We will try to fix it as soon as possible.
---------- Reason ----------
{}
----------------------------
",
$reason
))
};
}
#[expect(
clippy::panic,
reason = "called when code must fail to avoid undefined behaviour."
)]
pub fn safe_unreachable(reason: &str) -> ! {
panic!(
"
This is not meant to happen.
Please report this problem at https://github.com/t-webber/html-parser/issues/new.
Please include the code snippet that created this error and the reason displayed below.
Thank you for signalling this issue!
We will try to fix it as soon as possible.
---------- Reason ----------
{reason}
----------------------------
"
)
}
pub(super) use safe_expect;