@@ -285,6 +285,18 @@ impl HashStableEq for ::std::num::NonZeroUsize {
285285 }
286286}
287287
288+ impl HashStableEq for :: std:: num:: NonZeroU32 {
289+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
290+ self . get ( ) . hash_stable_eq ( & other. get ( ) )
291+ }
292+ }
293+
294+ impl HashStableEq for :: std:: num:: NonZeroU64 {
295+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
296+ self . get ( ) . hash_stable_eq ( & other. get ( ) )
297+ }
298+ }
299+
288300impl < CTX > HashStable < CTX > for f32 {
289301 fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
290302 let val: u32 = unsafe { :: std:: mem:: transmute ( * self ) } ;
@@ -424,6 +436,25 @@ impl<T: HashStableEq> HashStableEq for Vec<T> {
424436 }
425437}
426438
439+ impl < K : HashStableEq + Eq + Hash , V : HashStableEq , R : BuildHasher > HashStableEq for indexmap:: IndexMap < K , V , R > {
440+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
441+ if self . len ( ) != other. len ( ) {
442+ return false ;
443+ }
444+ // Equal maps will have equal iteration orders
445+ // FIXME -is that actually right?
446+ self . iter ( ) . zip ( other. iter ( ) ) . all ( |( first, second) | {
447+ first. hash_stable_eq ( & second)
448+ } )
449+ }
450+ }
451+
452+ impl < T > HashStableEq for std:: marker:: PhantomData < T > {
453+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
454+ true
455+ }
456+ }
457+
427458impl < K , V , R , CTX > HashStable < CTX > for indexmap:: IndexMap < K , V , R >
428459where
429460 K : HashStable < CTX > + Eq + Hash ,
@@ -463,6 +494,12 @@ where
463494 }
464495}
465496
497+ impl < A : smallvec:: Array > HashStableEq for SmallVec < A > where <A as smallvec:: Array >:: Item : HashStableEq {
498+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
499+ ( & self [ ..] ) . hash_stable_eq ( other)
500+ }
501+ }
502+
466503impl < T : ?Sized + HashStable < CTX > , CTX > HashStable < CTX > for Box < T > {
467504 #[ inline]
468505 fn hash_stable ( & self , ctx : & mut CTX , hasher : & mut StableHasher ) {
@@ -693,6 +730,49 @@ where
693730 }
694731}
695732
733+ impl < K , V , R > HashStableEq for :: std:: collections:: HashMap < K , V , R >
734+ where
735+ K : HashStableEq + Eq + Hash ,
736+ V : HashStableEq ,
737+ R : BuildHasher ,
738+ {
739+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
740+ if self . len ( ) != other. len ( ) {
741+ return false ;
742+ }
743+ self . iter ( ) . all ( |( key, value) | {
744+ match other. get_key_value ( key) {
745+ Some ( ( other_key, other_value) ) => {
746+ // Compare the key, since the `PartailEq` impl
747+ // used by the map may ignore information
748+ key. hash_stable_eq ( other_key) && value. hash_stable_eq ( other_value)
749+ }
750+ _ => false ,
751+ }
752+ } )
753+ }
754+ }
755+
756+ impl < K , R > HashStableEq for :: std:: collections:: HashSet < K , R >
757+ where
758+ K : HashStableEq + Eq + Hash ,
759+ R : BuildHasher ,
760+ {
761+ fn hash_stable_eq ( & self , other : & Self ) -> bool {
762+ if self . len ( ) != other. len ( ) {
763+ return false ;
764+ }
765+ self . iter ( ) . all ( |key| {
766+ match other. get ( key) {
767+ // Compare the key, since the `PartailEq` impl
768+ // used by the map may ignore information
769+ Some ( other_key) => key. hash_stable_eq ( other_key) ,
770+ None => false ,
771+ }
772+ } )
773+ }
774+ }
775+
696776impl < K , R , HCX > HashStable < HCX > for :: std:: collections:: HashSet < K , R >
697777where
698778 K : ToStableHashKey < HCX > + Eq ,
0 commit comments