Skip to content

Commit ec6c1ee

Browse files
committed
Restore impl Eq for BitFlags
1 parent e054c67 commit ec6c1ee

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib.rs

Lines changed: 10 additions & 4 deletions
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, Hash)]
323+
#[derive(Copy, Clone, Eq, Hash)]
324324
#[repr(transparent)]
325325
pub struct BitFlags<T, N = <T as _internal::RawBitFlags>::Numeric> {
326326
val: N,
@@ -691,13 +691,19 @@ for_each_uint! { $ty $hide_docs =>
691691
}
692692
}
693693

694-
impl<T, B> cmp::PartialEq<B> for BitFlags<T>
694+
impl<T, N: PartialEq> cmp::PartialEq for BitFlags<T, N> {
695+
#[inline(always)]
696+
fn eq(&self, other: &Self) -> bool {
697+
self.val == other.val
698+
}
699+
}
700+
701+
impl<T> cmp::PartialEq<T> for BitFlags<T>
695702
where
696703
T: BitFlag,
697-
B: Into<BitFlags<T>> + Copy,
698704
{
699705
#[inline(always)]
700-
fn eq(&self, other: &B) -> bool {
706+
fn eq(&self, other: &T) -> bool {
701707
self.bits() == Into::<Self>::into(*other).bits()
702708
}
703709
}

0 commit comments

Comments
 (0)