Merge pull request #292 from ariard/2019-12-serialization-test
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 1 Mar 2019 22:37:17 +0000 (17:37 -0500)
committerGitHub <noreply@github.com>
Fri, 1 Mar 2019 22:37:17 +0000 (17:37 -0500)
[Ready for Review] Add msgs serialization tests

src/ln/msgs.rs
src/util/logger.rs

index 6d04e5333c704f8cf7c5028f223499df10973919..125316d3fa81802d38255d41cdb06681d8423672 100644 (file)
@@ -91,25 +91,15 @@ impl LocalFeatures {
        }
 
        pub(crate) fn requires_unknown_bits(&self) -> bool {
-               for (idx, &byte) in self.flags.iter().enumerate() {
-                       if idx != 0 && (byte & 0x55) != 0 {
-                               return true;
-                       } else if idx == 0 && (byte & 0x14) != 0 {
-                               return true;
-                       }
-               }
-               return false;
+               self.flags.iter().enumerate().any(|(idx, &byte)| {
+                       ( idx != 0 && (byte & 0x55) != 0 ) || ( idx == 0 && (byte & 0x14) != 0 )
+               })
        }
 
        pub(crate) fn supports_unknown_bits(&self) -> bool {
-               for (idx, &byte) in self.flags.iter().enumerate() {
-                       if idx != 0 && byte != 0 {
-                               return true;
-                       } else if idx == 0 && (byte & 0xc4) != 0 {
-                               return true;
-                       }
-               }
-               return false;
+               self.flags.iter().enumerate().any(|(idx, &byte)| {
+                       ( idx != 0 && byte != 0 ) || ( idx == 0 && (byte & 0xc4) != 0 )
+               })
        }
 }
 
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> {