@@ -391,6 +391,18 @@ macro_rules! init_tlv_field_var {
391391 } ;
392392}
393393
394+ macro_rules! init_and_read_tlv_fields {
395+ ( $reader: ident, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => {
396+ $(
397+ init_tlv_field_var!( $field, $fieldty) ;
398+ ) *
399+
400+ read_tlv_fields!( $reader, {
401+ $( ( $type, $field, $fieldty) ) ,*
402+ } ) ;
403+ }
404+ }
405+
394406/// Implements Readable/Writeable for a struct storing it as a set of TLVs
395407/// If $fieldty is `required`, then $field is a required field that is not an Option nor a Vec.
396408/// If $fieldty is `option`, then $field is optional field.
@@ -425,12 +437,10 @@ macro_rules! impl_writeable_tlv_based {
425437
426438 impl $crate:: util:: ser:: Readable for $st {
427439 fn read<R : $crate:: io:: Read >( reader: & mut R ) -> Result <Self , $crate:: ln:: msgs:: DecodeError > {
428- $(
429- init_tlv_field_var!( $field, $fieldty) ;
430- ) *
431- read_tlv_fields!( reader, {
440+ init_and_read_tlv_fields!( reader, {
432441 $( ( $type, $field, $fieldty) ) ,*
433442 } ) ;
443+
434444 Ok ( Self {
435445 $(
436446 $field: init_tlv_based_struct_field!( $field, $fieldty)
0 commit comments