Skip to content

Commit ace3850

Browse files
feat: impl PartialEq<Out> for Expected<Out>
1 parent 20c3698 commit ace3850

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

moz-webgpu-cts/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ where
745745
where
746746
Out: Default + EnumSetType + Eq + PartialEq,
747747
{
748-
if exp != &Default::default() {
748+
if exp != &Out::default() {
749749
f()
750750
} else {
751751
Ok(())

moz-webgpu-cts/src/shared.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::metadata::{BuildProfile, Platform};
2424
///
2525
/// [`Test`]: crate::metadata::Test
2626
/// [`Subtest`]: crate::metadata::Subtest
27-
#[derive(Clone, Copy, Eq, PartialEq)]
27+
#[derive(Clone, Copy)]
2828
pub struct Expected<Out>(EnumSet<Out>)
2929
where
3030
Out: EnumSetType;
@@ -191,6 +191,26 @@ where
191191
}
192192
}
193193

194+
impl<Out> PartialEq for Expected<Out>
195+
where
196+
Out: EnumSetType + Eq,
197+
{
198+
fn eq(&self, other: &Self) -> bool {
199+
self.inner() == other.inner()
200+
}
201+
}
202+
203+
impl<Out> PartialEq<Out> for Expected<Out>
204+
where
205+
Out: EnumSetType + Eq,
206+
{
207+
fn eq(&self, other: &Out) -> bool {
208+
self.inner() == *other
209+
}
210+
}
211+
212+
impl<Out> Eq for Expected<Out> where Out: EnumSetType + Eq {}
213+
194214
/// Similar to the ubiquitous `enum Either`, but with the implication that `Collapsed` values are
195215
/// abbreviations of equivalent `Expanded` values.
196216
#[derive(Clone, Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)