1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::polymorphism::{ConstCmpMarker, IsAConstCmpMarker, IsNotStdKind, IsStdKind};
pub struct CmpWrapper<T>(pub T);
impl<'a, T> CmpWrapper<&'a [T]> {
#[inline(always)]
pub const fn slice(x: &'a [T]) -> Self {
Self { 0: x }
}
}
impl<P> ConstCmpMarker for CmpWrapper<P> {
type Kind = IsNotStdKind;
type This = Self;
}
macro_rules! std_kind_impls {
($($ty:ty),* $(,)* ) => (
$(
impl ConstCmpMarker for $ty {
type Kind = IsStdKind;
type This = Self;
}
impl<T> IsAConstCmpMarker<IsStdKind, $ty, T> {
#[inline(always)]
pub const fn coerce(self, reference: &$ty) -> CmpWrapper<$ty> {
CmpWrapper(*reference)
}
}
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,
}