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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use crate::alignment::Alignment;
use crate::bytes::AlignedBytes;
use crate::slice::AlignedSlice;
impl<A: Alignment> PartialEq for AlignedBytes<A> {
#[inline]
fn eq(&self, other: &Self) -> bool {
let slice: &AlignedSlice<A> = self;
let other_slice: &AlignedSlice<A> = other;
slice.eq(other_slice)
}
}
impl<A: Alignment> Eq for AlignedBytes<A> {}
impl<A: Alignment> PartialEq<AlignedBytes<A>> for Vec<u8> {
#[inline]
fn eq(&self, other: &AlignedBytes<A>) -> bool {
other.eq(self)
}
}
impl<A: Alignment> PartialEq<Vec<u8>> for AlignedBytes<A> {
#[inline]
fn eq(&self, other: &Vec<u8>) -> bool {
let slice: &AlignedSlice<A> = self;
let other_slice: &[u8] = other;
slice.eq(other_slice)
}
}
impl<A: Alignment> PartialEq<AlignedBytes<A>> for [u8] {
#[inline]
fn eq(&self, other: &AlignedBytes<A>) -> bool {
other.eq(self)
}
}
impl<A: Alignment> PartialEq<[u8]> for AlignedBytes<A> {
#[inline]
fn eq(&self, other: &[u8]) -> bool {
let slice: &AlignedSlice<A> = self;
slice.eq(other)
}
}
impl<A: Alignment, const N: usize> PartialEq<AlignedBytes<A>> for [u8; N] {
#[inline]
fn eq(&self, other: &AlignedBytes<A>) -> bool {
other.eq(self)
}
}
impl<A: Alignment, const N: usize> PartialEq<[u8; N]> for AlignedBytes<A> {
#[inline]
fn eq(&self, other: &[u8; N]) -> bool {
let slice: &AlignedSlice<A> = self;
slice.eq(other)
}
}
impl<A: Alignment> PartialOrd for AlignedBytes<A> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
let slice: &AlignedSlice<A> = self;
let other_slice: &AlignedSlice<A> = other;
slice.partial_cmp(other_slice)
}
}
impl<A: Alignment> Ord for AlignedBytes<A> {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let slice: &AlignedSlice<A> = self;
let other_slice: &AlignedSlice<A> = other;
slice.cmp(other_slice)
}
}
impl<A: Alignment> std::hash::Hash for AlignedBytes<A> {
#[inline]
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
std::hash::Hash::hash(&self.as_ptr(), state)
}
}