projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Drop uneccessary `if {...; bool}` pattern in PeerManager
[rust-lightning]
/
lightning
/
src
/
util
/
ser_macros.rs
diff --git
a/lightning/src/util/ser_macros.rs
b/lightning/src/util/ser_macros.rs
index 165d1f1edbacea61438ef3426828a1195336a39e..351c2a1f5e25e4d21ad0c999e2f064bf366a6f35 100644
(file)
--- a/
lightning/src/util/ser_macros.rs
+++ b/
lightning/src/util/ser_macros.rs
@@
-99,7
+99,7
@@
macro_rules! check_tlv_order {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
if invalid_order {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
if invalid_order {
- $field = $default;
+ $field = $default
.into()
;
}
}};
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, required) => {{
}
}};
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, required) => {{
@@
-118,6
+118,9
@@
macro_rules! check_tlv_order {
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
+ ($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
+ // no-op
+ }};
}
macro_rules! check_missing_tlv {
}
macro_rules! check_missing_tlv {
@@
-125,7
+128,7
@@
macro_rules! check_missing_tlv {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
if missing_req_type {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
if missing_req_type {
- $field = $default;
+ $field = $default
.into()
;
}
}};
($last_seen_type: expr, $type: expr, $field: ident, required) => {{
}
}};
($last_seen_type: expr, $type: expr, $field: ident, required) => {{
@@
-144,6
+147,9
@@
macro_rules! check_missing_tlv {
($last_seen_type: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
($last_seen_type: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
+ ($last_seen_type: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
+ // no-op
+ }};
}
macro_rules! decode_tlv {
}
macro_rules! decode_tlv {
@@
-163,6
+169,9
@@
macro_rules! decode_tlv {
($reader: expr, $field: ident, ignorable) => {{
$field = ser::MaybeReadable::read(&mut $reader)?;
}};
($reader: expr, $field: ident, ignorable) => {{
$field = ser::MaybeReadable::read(&mut $reader)?;
}};
+ ($reader: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
+ $field = Some($trait::read(&mut $reader $(, $read_arg)*)?);
+ }};
}
macro_rules! decode_tlv_stream {
}
macro_rules! decode_tlv_stream {
@@
-340,7
+349,7
@@
macro_rules! read_tlv_fields {
macro_rules! init_tlv_based_struct_field {
($field: ident, (default_value, $default: expr)) => {
macro_rules! init_tlv_based_struct_field {
($field: ident, (default_value, $default: expr)) => {
- $field
+ $field
.0.unwrap()
};
($field: ident, option) => {
$field
};
($field: ident, option) => {
$field
@@
-355,7
+364,7
@@
macro_rules! init_tlv_based_struct_field {
macro_rules! init_tlv_field_var {
($field: ident, (default_value, $default: expr)) => {
macro_rules! init_tlv_field_var {
($field: ident, (default_value, $default: expr)) => {
- let mut $field =
$default
;
+ let mut $field =
::util::ser::OptionDeserWrapper(None)
;
};
($field: ident, required) => {
let mut $field = ::util::ser::OptionDeserWrapper(None);
};
($field: ident, required) => {
let mut $field = ::util::ser::OptionDeserWrapper(None);