Skip to main content

libutils_array/
comparisons.rs

1//^
2//^ HEAD
3//^
4
5//> HEAD -> SUPER
6use super::Array;
7
8//> HEAD -> CORE
9use core::{
10    hash::{
11        Hash,
12        Hasher
13    },
14    cmp::Ordering
15};
16
17
18//^
19//^ COMPARISONS
20//^
21
22//> COMPARISONS -> EQ
23const impl<
24    Type: [const] PartialEq<Type>, 
25    To: [const] AsRef<[Type]>, 
26    const N: usize
27> PartialEq<To> for Array<Type, N> {
28    #[inline]
29    fn eq(&self, other: &To) -> bool {return self.as_ref().eq(other.as_ref())}
30}
31
32//> COMPARISONS -> ORD
33const impl<
34    Type: [const] PartialOrd<Type>, 
35    To: [const] AsRef<[Type]>, 
36    const N: usize
37> PartialOrd<To> for Array<Type, N> {
38    #[inline]
39    fn partial_cmp(&self, other: &To) -> Option<Ordering> {return self.as_ref().partial_cmp(other.as_ref())}
40}
41
42//> COMPARISONS -> HASH
43impl<Type: Hash, const N: usize> Hash for Array<Type, N> {
44    #[inline]
45    fn hash<Hashing: Hasher>(&self, state: &mut Hashing) {return Hash::hash(self.as_ref(), state)}
46}
47
48//> COMPARISONS -> TOTAL EQ
49const impl<Type: [const] Eq, const N: usize> Eq for Array<Type, N> {}
50
51//> COMPARISONS -> TOTAL ORD
52const impl<Type: [const] Ord, const N: usize> Ord for Array<Type, N> {
53    #[inline]
54    fn cmp(&self, other: &Self) -> Ordering {return self.as_ref().cmp(other.as_ref())}
55}