Skip to content

Commit 3a64154

Browse files
xNxExOxmeithecatte
authored andcommitted
Implement Hash manually to appease Clippy
1 parent c375ee4 commit 3a64154

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ pub use crate::fallible::FromBitsError;
320320
/// The types substituted for `T` and `N` must always match, creating a
321321
/// `BitFlags` value where that isn't the case is considered to be impossible
322322
/// without unsafe code.
323-
#[derive(Copy, Clone, Eq, Hash)]
323+
#[derive(Copy, Clone, Eq)]
324324
#[repr(transparent)]
325325
pub struct BitFlags<T, N = <T as _internal::RawBitFlags>::Numeric> {
326326
val: N,
@@ -698,6 +698,14 @@ impl<T, N: PartialEq> cmp::PartialEq for BitFlags<T, N> {
698698
}
699699
}
700700

701+
// Clippy complains when Hash is derived while PartialEq is implemented manually
702+
impl<T, N: core::hash::Hash> core::hash::Hash for BitFlags<T, N> {
703+
#[inline(always)]
704+
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
705+
self.val.hash(state)
706+
}
707+
}
708+
701709
impl<T> cmp::PartialEq<T> for BitFlags<T>
702710
where
703711
T: BitFlag,

0 commit comments

Comments
 (0)