From: Carl Dong Date: Thu, 7 Feb 2019 18:16:17 +0000 (-0500) Subject: msgs: Reformulate unknown bits calculation w/ any X-Git-Tag: v0.0.12~226^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e91b6469f35c1f0c4a7f2fc48291e70e892a9b26;p=rust-lightning msgs: Reformulate unknown bits calculation w/ any --- 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 ) + }) } }