From efa579bc61eafaae509657e57c6442c0c9229915 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 1 Aug 2021 02:34:08 +0000 Subject: [PATCH] Don't initialise Vecs being read with VecReadWrapper explicitly This simplifies the tlv serialization read macro somewhat by allowing callsites to simply read into an `Option` instead of needing to read into an `Option` when using `vec_type`. --- lightning/src/util/ser_macros.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index 5178732c7..e8bd3326b 100644 --- a/lightning/src/util/ser_macros.rs +++ b/lightning/src/util/ser_macros.rs @@ -154,7 +154,8 @@ macro_rules! decode_tlv { $field = ser::Readable::read(&mut $reader)?; }}; ($reader: expr, $field: ident, vec_type) => {{ - $field = Some(ser::Readable::read(&mut $reader)?); + let f: ::util::ser::VecReadWrapper<_> = ser::Readable::read(&mut $reader)?; + $field = Some(f.0); }}; ($reader: expr, $field: ident, option) => {{ $field = Some(ser::Readable::read(&mut $reader)?); @@ -399,7 +400,7 @@ macro_rules! init_tlv_based_struct_field { $field.0.unwrap() }; ($field: ident, vec_type) => { - $field.unwrap().0 + $field.unwrap() }; } @@ -411,7 +412,7 @@ macro_rules! init_tlv_field_var { let mut $field = ::util::ser::OptionDeserWrapper(None); }; ($field: ident, vec_type) => { - let mut $field = Some(::util::ser::VecReadWrapper(Vec::new())); + let mut $field = Some(Vec::new()); }; ($field: ident, option) => { let mut $field = None; -- 2.39.5