]> git.bitcoin.ninja Git - rust-lightning/commitdiff
msgs: Reformulate unknown bits calculation w/ any
authorCarl Dong <accounts@carldong.me>
Thu, 7 Feb 2019 18:16:17 +0000 (13:16 -0500)
committerCarl Dong <accounts@carldong.me>
Thu, 7 Feb 2019 18:16:17 +0000 (13:16 -0500)
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 )
+               })
        }
 }