-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomparisons.rs
More file actions
55 lines (46 loc) · 1.17 KB
/
Copy pathcomparisons.rs
File metadata and controls
55 lines (46 loc) · 1.17 KB
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
55
//^
//^ HEAD
//^
//> HEAD -> SUPER
use super::Array;
//> HEAD -> CORE
use core::{
hash::{
Hash,
Hasher
},
cmp::Ordering
};
//^
//^ COMPARISONS
//^
//> COMPARISONS -> EQ
const impl<
Type: [const] PartialEq<Type>,
To: [const] AsRef<[Type]>,
const N: usize
> PartialEq<To> for Array<Type, N> {
fn eq(&self, other: &To) -> bool {return self.as_ref().eq(other.as_ref())}
}
//> COMPARISONS -> ORD
const impl<
Type: [const] PartialOrd<Type>,
To: [const] AsRef<[Type]>,
const N: usize
> PartialOrd<To> for Array<Type, N> {
fn partial_cmp(&self, other: &To) -> Option<Ordering> {
return self.as_ref().partial_cmp(other.as_ref());
}
}
//> COMPARISONS -> HASH
impl<Type: Hash, const N: usize> Hash for Array<Type, N> {
fn hash<Hashing: Hasher>(&self, state: &mut Hashing) {
return Hash::hash(self.as_ref(), state);
}
}
//> COMPARISONS -> TOTAL EQ
const impl<Type: [const] Eq, const N: usize> Eq for Array<Type, N> {}
//> COMPARISONS -> TOTAL ORD
const impl<Type: [const] Ord, const N: usize> Ord for Array<Type, N> {
fn cmp(&self, other: &Self) -> Ordering {return self.as_ref().cmp(other.as_ref())}
}