Macro std::unreachable
Treats the location as unreachable during program flow.
In debug mode, this macro will panic if ever reached. In release mode, it will cause
undefined behavior. This is a way to satisfy type-checker, especially useful in switch
expressions.
Example
let number: i32 = 42;
switch number % 3 {
0 => "odd",
1 => "even",
2 => "what even?",
_ => unreachable!()
};
Run this example