mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Enable all feature sets to OR with another set of the same type
This commit is contained in:
parent
3fb3218b6c
commit
fe8b4c7836
1 changed files with 11 additions and 10 deletions
|
@ -470,6 +470,17 @@ pub struct Features<T: sealed::Context> {
|
|||
mark: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl <T: sealed::Context> Features<T> {
|
||||
pub(crate) fn or(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()) {
|
||||
*byte |= *o_byte;
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: sealed::Context> Clone for Features<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
|
@ -532,16 +543,6 @@ impl InitFeatures {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// or's another InitFeatures into this one.
|
||||
pub(crate) fn or(mut self, o: InitFeatures) -> InitFeatures {
|
||||
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()) {
|
||||
*byte |= *o_byte;
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Converts `InitFeatures` to `Features<C>`. Only known `InitFeatures` relevant to context `C`
|
||||
/// are included in the result.
|
||||
pub(crate) fn to_context<C: sealed::Context>(&self) -> Features<C> {
|
||||
|
|
Loading…
Add table
Reference in a new issue