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