Merge pull request #308 from dongcarl/2019-02-reformulate-unknown-bits-calculation
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Sun, 24 Feb 2019 19:27:19 +0000 (14:27 -0500)
committerGitHub <noreply@github.com>
Sun, 24 Feb 2019 19:27:19 +0000 (14:27 -0500)
msgs: Reformulate unknown bits calculation w/ any

src/ln/msgs.rs

index f00dc34a50024a48d36c9a0ebf3c0dc695567f3b..97f3c9474c46b8f88c0b808bf9b71ffc6784cb75 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 )
+               })
        }
 }