Macro mycelium_util::unreachable_unchecked
source · macro_rules! unreachable_unchecked { () => { ... }; ($msg:expr) => { ... }; ($msg:expr,) => { ... }; ($fmt:expr, $($arg:tt)*) => { ... }; }
Expand description
Indicates unreachable code that we are confident is truly unreachable.
This is essentially a compromise between core::unreachable!()
and
core::hint::unreachable_unchecked()
. In debug mode builds and in tests,
this expands to unreachable!()
, causing a panic. However, in release mode
non-test builds, this expands to unreachable_unchecked
. Thus, this is a
somewhat safer form of unreachable_unchecked
that will allow cases where
unreachable_unchecked
would be invalid to be detected early.
Nonetheless, this must still be used with caution! If code is not adequately
tested, it is entirely possible for the unreachable_unchecked
to be
reached in a scenario that was not reachable in tests.