util: Derive PartialEq for Level
authorCarl Dong <accounts@carldong.me>
Thu, 7 Feb 2019 18:08:21 +0000 (13:08 -0500)
committerCarl Dong <accounts@carldong.me>
Thu, 7 Feb 2019 18:08:21 +0000 (13:08 -0500)
PartialEq, Eq, and Hash should all be derived together wherever possible
to not violate Hash invariants. See the documentation for
std::hash::Hash for more details.

src/util/logger.rs

index 82b8e3ea57d8d7351cc029913ee4995209e89085..e727723c16dedbc6bb4713b4bd137238884ce0b5 100644 (file)
@@ -21,7 +21,7 @@ use std::sync::Arc;
 static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE"];
 
 /// An enum representing the available verbosity levels of the logger.
-#[derive(Copy, Clone, Eq, Debug, Hash)]
+#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
 pub enum Level {
        ///Designates logger being silent
        Off,
@@ -37,13 +37,6 @@ pub enum Level {
        Trace,
 }
 
-impl PartialEq for Level {
-       #[inline]
-       fn eq(&self, other: &Level) -> bool {
-               *self as usize == *other as usize
-       }
-}
-
 impl PartialOrd for Level {
        #[inline]
        fn partial_cmp(&self, other: &Level) -> Option<cmp::Ordering> {