if never!(impossible_condition) {
// The impossible happened 💔
// This would have panicked in debug.
// in release we get a chance for best-effort recovery.
return None;
}
This is useful for long-running applications, which can't just printf("Sucks to be you"); exit(666) if things go south. I am somewhat embarrassed that that it took me so long to realize this pattern exists: seems obvious in retrospect!
It would be nice to have #[must_use] on that, so it's not just used as a shorthand for debug_assert, but I guess you'd need stable expression attributes.
#[doc(hidden)] #[must_use] pub fn __use_me<T>(t: T) -> T { t } would work, but I don't think that would be good -- in rust-analyzer a significant fraction of cases require a do-nothing recovery.