use crate::cmp::{ConstCmp, IsNotStdKind, IsStdKind};
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct CmpWrapper<T: ?Sized>(pub T);
impl CmpWrapper<()> {
#[inline(always)]
pub const fn from_ref<T: ?Sized>(x: &T) -> &CmpWrapper<T> {
unsafe { &*(x as *const T as *const CmpWrapper<T>) }
}
}
impl<P> ConstCmp for CmpWrapper<P> {
type Kind = IsNotStdKind;
type This = Self;
}
macro_rules! std_kind_impls {
($($ty:ty),* $(,)* ) => (
$(
impl ConstCmp for $ty {
type Kind = IsStdKind;
type This = Self;
}
impl CmpWrapper<$ty> {
#[inline(always)]
pub const fn const_eq(&self, other: &$ty) -> bool {
self.0 == *other
}
}
)*
)
}
std_kind_impls! {
i8, u8,
i16, u16,
i32, u32,
i64, u64,
i128, u128,
isize, usize,
bool, char,
}