1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/// Panics if reached. This is a variant of the standard library's `unreachable!`
/// macro that is controlled by `cfg!(debug_assertions)`.
///
/// Same as prelude's `unreachable!` in debug builds or release builds where the
/// `-C debug-assertions` was provided to the compiler. For all other builds,
/// vanishes without a trace.
///
/// # Example
///
/// ```rust
/// // You probably wouldn't actually use this here
/// let mut value = 0.5;
/// if value < 0.0 {
/// chek::debug_unreachable!("Value out of range {}", value);
/// value = 0.0;
/// }
/// ```
/// In debug mode, panics if reached (with `unreachable!`). In release mode, is
/// a `std::hint::unreachable_unchecked()` call. This is `unsafe` to call in
/// both debug and release builds.
///
/// # Example
///
/// ```rust
/// let value = Some(10);
/// // Obviously, be extremely sure you're correct if you use this.
/// let contents = value.unwrap_or_else(|| unsafe {
/// chek::debug_unreachable_unchecked!("optional message")
/// });
/// ```