Skip to content

Commit ae56cb0

Browse files
ordovicialevex
authored andcommitted
Use mem::discriminant in impl PartialEq for CgroupError
1 parent 2149e1c commit ae56cb0

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

src/lib.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -92,38 +92,8 @@ pub enum CgroupError {
9292

9393
impl PartialEq for CgroupError {
9494
fn eq(&self, other: &CgroupError) -> bool {
95-
match self {
96-
CgroupError::WriteError(_) => if let CgroupError::WriteError(_) = other {
97-
return true;
98-
} else {
99-
return false;
100-
},
101-
CgroupError::ReadError(_) => if let CgroupError::ReadError(_) = other {
102-
return true;
103-
} else {
104-
return false;
105-
},
106-
CgroupError::ParseError => if let CgroupError::ParseError = other {
107-
return true;
108-
} else {
109-
return false;
110-
},
111-
CgroupError::InvalidOperation => if let CgroupError::InvalidOperation = other {
112-
return true;
113-
} else {
114-
return false;
115-
},
116-
CgroupError::InvalidPath => if let CgroupError::InvalidPath = other {
117-
return true;
118-
} else {
119-
return false;
120-
},
121-
CgroupError::Unknown => if let CgroupError::Unknown = other {
122-
return true;
123-
} else {
124-
return false;
125-
},
126-
}
95+
use std::mem::discriminant;
96+
discriminant(&self) == discriminant(&other)
12797
}
12898
}
12999

0 commit comments

Comments
 (0)