diff --git a/src/lib.rs b/src/lib.rs index 47c5f68..f34d370 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,38 +92,8 @@ pub enum CgroupError { impl PartialEq for CgroupError { fn eq(&self, other: &CgroupError) -> bool { - match self { - CgroupError::WriteError(_) => if let CgroupError::WriteError(_) = other { - return true; - } else { - return false; - }, - CgroupError::ReadError(_) => if let CgroupError::ReadError(_) = other { - return true; - } else { - return false; - }, - CgroupError::ParseError => if let CgroupError::ParseError = other { - return true; - } else { - return false; - }, - CgroupError::InvalidOperation => if let CgroupError::InvalidOperation = other { - return true; - } else { - return false; - }, - CgroupError::InvalidPath => if let CgroupError::InvalidPath = other { - return true; - } else { - return false; - }, - CgroupError::Unknown => if let CgroupError::Unknown = other { - return true; - } else { - return false; - }, - } + use std::mem::discriminant; + discriminant(&self) == discriminant(&other) } }