From e91b6469f35c1f0c4a7f2fc48291e70e892a9b26 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Thu, 7 Feb 2019 13:16:17 -0500 Subject: [PATCH] msgs: Reformulate unknown bits calculation w/ any --- src/ln/msgs.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index f00dc34a5..97f3c9474 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -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 ) + }) } } -- 2.39.5