From: Jeffrey Czyz Date: Thu, 13 Apr 2023 18:06:14 +0000 (-0500) Subject: Define core::ops::BitOr for Features X-Git-Tag: v0.0.116-alpha1~35^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=687e587a73d53b58687cc79db28aa21f2908b7cc;p=rust-lightning Define core::ops::BitOr for Features The `lightning-custom-message` crate will need access to Features::or in order combine features of a composite handler. Expose this via a core::ops::BitOr implementation. --- diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 8ccbf4166..f0e2f112a 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -422,8 +422,10 @@ pub struct Features { mark: PhantomData, } -impl Features { - pub(crate) fn or(mut self, o: Self) -> Self { +impl core::ops::BitOr for Features { + type Output = Self; + + fn bitor(mut self, o: Self) -> Self { let total_feature_len = cmp::max(self.flags.len(), o.flags.len()); self.flags.resize(total_feature_len, 0u8); for (byte, o_byte) in self.flags.iter_mut().zip(o.flags.iter()) { diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index df6a2aba3..02b7b0949 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1392,7 +1392,7 @@ impl Readable for Init { (3, remote_network_address, option) }); Ok(Init { - features: features.or(global_features), + features: features | global_features, remote_network_address, }) } diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 046bbad92..bb6d4b1c5 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1246,8 +1246,8 @@ impl