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    fn eq(&self, other: &To) -> bool {return self.as_ref().eq(other.as_ref())}
29}
30
31//> COMPARISONS -> ORD
32const impl<
33    Type: [const] PartialOrd<Type>, 
34    To: [const] AsRef<[Type]>, 
35    const N: usize
36> PartialOrd<To> for Array<Type, N> {
37    fn partial_cmp(&self, other: &To) -> Option<Ordering> {return self.as_ref().partial_cmp(other.as_ref())}
38}
39
40//> COMPARISONS -> HASH
41impl<Type: Hash, const N: usize> Hash for Array<Type, N> {
42    fn hash<Hashing: Hasher>(&self, state: &mut Hashing) {return Hash::hash(self.as_ref(), state)}
43}
44
45//> COMPARISONS -> TOTAL EQ
46const impl<Type: [const] Eq, const N: usize> Eq for Array<Type, N> {}
47
48//> COMPARISONS -> TOTAL ORD
49const impl<Type: [const] Ord, const N: usize> Ord for Array<Type, N> {
50    fn cmp(&self, other: &Self) -> Ordering {return self.as_ref().cmp(other.as_ref())}
51}