SHARE
TWEET

Untitled

a guest Oct 21st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// Uses `unreachable!()` in debug mode but `std::hint::unreachable_unchecked()`
  2. /// in release mode.
  3. unsafe fn unreachable_debug() {
  4.     #[cfg(debug_assertions)]
  5.     unreachable!();
  6.     #[cfg(not(debug_assertions))]
  7.     std::hint::unreachable_unchecked();
  8. }
  9.  
  10. fn main() {
  11.     match 1 {
  12.         1 => {},
  13.         _ => unsafe { unreachable_debug() },
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top