add Hash to ArrayVec and TinyVec

This commit is contained in:
Lokathor
2020-01-20 18:48:18 -07:00
parent 5306d4dc7e
commit 08a8db9a3f
3 changed files with 9 additions and 26 deletions
+4 -13
View File
@@ -918,24 +918,15 @@ where
}
}
/*
I think, in retrospect, this is useless?
The `&mut [A::Item]` should coerce to `&[A::Item]` and use the above impl.
I'll leave it here for now though since we already had it written out..
impl<A: Array> PartialEq<&mut [A::Item]> for ArrayVec<A>
impl<A: Array> Hash for ArrayVec<A>
where
A::Item: PartialEq,
A::Item: Hash,
{
#[inline]
#[must_use]
fn eq(&self, other: &&mut [A::Item]) -> bool {
self.deref() == *other
fn hash<H: Hasher>(&self, state: &mut H) {
self.as_slice().hash(state)
}
}
*/
// //
// Formatting impls
+1
View File
@@ -66,6 +66,7 @@ use core::{
Binary, Debug, Display, Formatter, LowerExp, LowerHex, Octal, Pointer,
UpperExp, UpperHex,
},
hash::{Hash, Hasher},
iter::{Extend, FromIterator, IntoIterator, Iterator},
mem::{needs_drop, replace},
ops::{Deref, DerefMut, Index, IndexMut, RangeBounds},
+4 -13
View File
@@ -792,24 +792,15 @@ where
}
}
/*
I think, in retrospect, this is useless?
The `&mut [A::Item]` should coerce to `&[A::Item]` and use the above impl.
I'll leave it here for now though since we already had it written out..
impl<A: Array> PartialEq<&mut [A::Item]> for TinyVec<A>
impl<A: Array> Hash for TinyVec<A>
where
A::Item: PartialEq,
A::Item: Hash,
{
#[inline]
#[must_use]
fn eq(&self, other: &&mut [A::Item]) -> bool {
self.deref() == *other
fn hash<H: Hasher>(&self, state: &mut H) {
self.as_slice().hash(state)
}
}
*/
// //
// Formatting impls