Skip to content

Commit 591362f

Browse files
authored
Merge pull request #308 from dongcarl/2019-02-reformulate-unknown-bits-calculation
msgs: Reformulate unknown bits calculation w/ any
2 parents 788bd91 + e91b646 commit 591362f

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/ln/msgs.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,15 @@ impl LocalFeatures {
9191
}
9292

9393
pub(crate) fn requires_unknown_bits(&self) -> bool {
94-
for (idx, &byte) in self.flags.iter().enumerate() {
95-
if idx != 0 && (byte & 0x55) != 0 {
96-
return true;
97-
} else if idx == 0 && (byte & 0x14) != 0 {
98-
return true;
99-
}
100-
}
101-
return false;
94+
self.flags.iter().enumerate().any(|(idx, &byte)| {
95+
( idx != 0 && (byte & 0x55) != 0 ) || ( idx == 0 && (byte & 0x14) != 0 )
96+
})
10297
}
10398

10499
pub(crate) fn supports_unknown_bits(&self) -> bool {
105-
for (idx, &byte) in self.flags.iter().enumerate() {
106-
if idx != 0 && byte != 0 {
107-
return true;
108-
} else if idx == 0 && (byte & 0xc4) != 0 {
109-
return true;
110-
}
111-
}
112-
return false;
100+
self.flags.iter().enumerate().any(|(idx, &byte)| {
101+
( idx != 0 && byte != 0 ) || ( idx == 0 && (byte & 0xc4) != 0 )
102+
})
113103
}
114104
}
115105

0 commit comments

Comments
 (0)