movable_ref/pointer/
unreachable.rs1pub(crate) const OVERFLOW_SUB: &str =
2 "Attempted to subtract with overflow, this is UB in release mode!";
3
4pub(crate) trait UncheckedOptionExt {
10 type T;
11
12 unsafe fn unchecked_unwrap(self, err: &str) -> Self::T;
13}
14
15impl<T> UncheckedOptionExt for Option<T> {
16 type T = T;
17
18 #[inline]
19 #[allow(clippy::assertions_on_constants)]
20 unsafe fn unchecked_unwrap(self, err: &str) -> T {
21 match self {
22 Some(value) => value,
23 None if cfg!(debug_assertions) => panic!("{}", err),
24 None => std::hint::unreachable_unchecked(),
25 }
26 }
27}