1use core::fmt::Debug;
2
3#[derive(Debug)]
5pub enum Never {}
6
7pub trait UnwrapNever<T> {
8 fn unwrap_never(self) -> T;
9}
10
11impl<T> UnwrapNever<T> for Result<T, Never> {
12 #[inline(always)]
13 fn unwrap_never(self) -> T {
14 match self {
15 Ok(x) => x,
16 Err(e) => match e {},
17 }
18 }
19}
20
21pub fn is_older_version(a: u32, b: u32) -> bool {
24 let diff = a.wrapping_sub(b);
25 diff >= (1 << 31)
26}
27
28pub struct PanicOnDrop(pub &'static str);
29impl Drop for PanicOnDrop {
30 fn drop(&mut self) {
31 panic!("{}", self.0);
32 }
33}