From: Matt Corallo Date: Sun, 1 Aug 2021 02:34:08 +0000 (+0000) Subject: Don't initialise Vecs being read with VecReadWrapper explicitly X-Git-Tag: v0.0.101~19^2~10 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=rust-lightning;a=commitdiff_plain;h=efa579bc61eafaae509657e57c6442c0c9229915 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`. --- diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index 5178732c..e8bd3326 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;