diff --git a/src/read/endian_reader.rs b/src/read/endian_reader.rs index c35267ef..5e65b4d1 100644 --- a/src/read/endian_reader.rs +++ b/src/read/endian_reader.rs @@ -5,6 +5,7 @@ use alloc::rc::Rc; use alloc::string::String; use alloc::sync::Arc; use core::fmt::Debug; +use core::hash::{Hash, Hasher}; use core::ops::{Deref, Index, Range, RangeFrom, RangeTo}; use core::slice; use core::str; @@ -116,7 +117,7 @@ pub type EndianArcSlice = EndianReader>; /// pub type MmapFileReader = gimli::EndianReader; /// # fn test(_: &MmapFileReader) { } /// ``` -#[derive(Debug, Clone, Copy, Hash)] +#[derive(Debug, Clone, Copy)] pub struct EndianReader where Endian: Endianity, @@ -144,6 +145,17 @@ where { } +impl Hash for EndianReader +where + Endian: Endianity, + T: CloneStableDeref + Debug, +{ + fn hash(&self, state: &mut H) { + // This must match the `PartialEq` implementation. + self.bytes().hash(state); + } +} + // This is separated out from `EndianReader` so that we can avoid running afoul // of borrowck. We need to `read_slice(&mut self, ...) -> &[u8]` and then call // `self.endian.read_whatever` on the result. The problem is that the returned