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