@@ -5,6 +5,7 @@ use alloc::rc::Rc;
55use alloc:: string:: String ;
66use alloc:: sync:: Arc ;
77use core:: fmt:: Debug ;
8+ use core:: hash:: { Hash , Hasher } ;
89use core:: ops:: { Deref , Index , Range , RangeFrom , RangeTo } ;
910use core:: slice;
1011use core:: str;
@@ -116,7 +117,7 @@ pub type EndianArcSlice<Endian> = EndianReader<Endian, Arc<[u8]>>;
116117/// pub type MmapFileReader<Endian> = gimli::EndianReader<Endian, ArcMmapFile>;
117118/// # fn test(_: &MmapFileReader<gimli::NativeEndian>) { }
118119/// ```
119- #[ derive( Debug , Clone , Copy , Hash ) ]
120+ #[ derive( Debug , Clone , Copy ) ]
120121pub struct EndianReader < Endian , T >
121122where
122123 Endian : Endianity ,
@@ -144,6 +145,17 @@ where
144145{
145146}
146147
148+ impl < Endian , T > Hash for EndianReader < Endian , T >
149+ where
150+ Endian : Endianity ,
151+ T : CloneStableDeref < Target = [ u8 ] > + Debug ,
152+ {
153+ fn hash < H : Hasher > ( & self , state : & mut H ) {
154+ // This must match the `PartialEq` implementation.
155+ self . bytes ( ) . hash ( state) ;
156+ }
157+ }
158+
147159// This is separated out from `EndianReader` so that we can avoid running afoul
148160// of borrowck. We need to `read_slice(&mut self, ...) -> &[u8]` and then call
149161// `self.endian.read_whatever` on the result. The problem is that the returned
0 commit comments