|
29 | 29 | #![deny(warnings)] |
30 | 30 | #![cfg_attr(not(test), no_std)] |
31 | 31 |
|
32 | | -use core::fmt::{Display, Debug}; |
33 | | -use core::ops; |
| 32 | +use core::{cmp::Ordering, fmt::{Display, Debug}, hash::{Hash, Hasher}, ops}; |
34 | 33 |
|
35 | 34 | use as_slice::{AsMutSlice, AsSlice}; |
36 | 35 |
|
@@ -172,6 +171,52 @@ where |
172 | 171 | } |
173 | 172 | } |
174 | 173 |
|
| 174 | +impl<A, T> PartialEq for Aligned<A, T> |
| 175 | +where |
| 176 | + A: sealed::Alignment, |
| 177 | + T: PartialEq, |
| 178 | +{ |
| 179 | + fn eq(&self, other: &Self) -> bool { |
| 180 | + self.value == other.value |
| 181 | + } |
| 182 | +} |
| 183 | + |
| 184 | +impl<A, T> Eq for Aligned<A, T> |
| 185 | +where |
| 186 | + A: sealed::Alignment, |
| 187 | + T: Eq, |
| 188 | +{} |
| 189 | + |
| 190 | +impl<A, T> Hash for Aligned<A, T> |
| 191 | +where |
| 192 | + A: sealed::Alignment, |
| 193 | + T: Hash, |
| 194 | +{ |
| 195 | + fn hash<H: Hasher>(&self, state: &mut H) { |
| 196 | + self.value.hash(state); |
| 197 | + } |
| 198 | +} |
| 199 | + |
| 200 | +impl<A, T> Ord for Aligned<A, T> |
| 201 | +where |
| 202 | + A: sealed::Alignment, |
| 203 | + T: Ord, |
| 204 | +{ |
| 205 | + fn cmp(&self, other: &Self) -> Ordering { |
| 206 | + self.value.cmp(&other.value) |
| 207 | + } |
| 208 | +} |
| 209 | + |
| 210 | +impl<A, T> PartialOrd for Aligned<A, T> |
| 211 | +where |
| 212 | + A: sealed::Alignment, |
| 213 | + T: PartialOrd, |
| 214 | +{ |
| 215 | + fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
| 216 | + self.value.partial_cmp(&other.value) |
| 217 | + } |
| 218 | +} |
| 219 | + |
175 | 220 | #[test] |
176 | 221 | fn sanity() { |
177 | 222 | use core::mem; |
|
0 commit comments