mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-19 14:23:33 -04:00
add Hash to ArrayVec and TinyVec
This commit is contained in:
+4
-13
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user