Skip to content

Commit

Permalink
f - support multiple patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
jkczyz committed Nov 4, 2022
1 parent 765f455 commit 130921b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! composite_custom_message_handler {
}

$message_visibility:vis enum $message:ident {
$($variant:ident($range:pat)),* $(,)*
$($variant:ident($($pattern:pat)|+)),* $(,)*
}
) => {
#[allow(missing_docs)]
Expand All @@ -92,10 +92,12 @@ macro_rules! composite_custom_message_handler {
) -> Result<Option<Self::CustomMessage>, msgs::DecodeError> {
match message_type {
$(
$range => match <$type>::read(&self.$field, message_type, buffer)? {
None => unreachable!(),
Some(message) => Ok(Some($message::$variant(message))),
},
$(
$pattern => match <$type>::read(&self.$field, message_type, buffer)? {
None => unreachable!(),
Some(message) => Ok(Some($message::$variant(message))),
},
)*
)*
_ => Ok(None),
}
Expand Down Expand Up @@ -131,8 +133,8 @@ composite_custom_message_handler!(
}

pub enum CompositeMessage {
Infallible(0),
Infallible2(1..=10),
Infallible(0 | 2 | 4),
Infallible2(1..=10 | 99),
}
);

Expand Down

0 comments on commit 130921b

Please sign in to comment.