From ae56cb02b9d06c0fe6f759be43f94681592ef26c Mon Sep 17 00:00:00 2001 From: Hidehito Yabuuchi Date: Thu, 4 Oct 2018 00:57:13 +0900 Subject: [PATCH] Use mem::discriminant in impl PartialEq for CgroupError --- src/lib.rs | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) 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) } }