1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Polyfill for `Option::unwrap()` as a const fn; feature `const_option`.
/// https://github.com/rust-lang/rust/issues/67441.
/// TODO(MSRV): Replace this with `x.unwrap()`.
///
/// `T: Copy` avoids "constant functions cannot evaluate destructors."
pub const fn unwrap_const<T>(x: Option<T>) -> T
where
    T: Copy,
{
    if let Some(x) = x {
        x
    } else {
        panic!("unwrap_const on `None`");
    }
}