From d1858f8963f5f3026d9c065407c0d5829548a494 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Mon, 4 Dec 2023 18:35:42 +0100 Subject: [PATCH] Change XCM builder methods to take and return mutable references --- polkadot/xcm/procedural/src/builder_pattern.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/procedural/src/builder_pattern.rs b/polkadot/xcm/procedural/src/builder_pattern.rs index 1cb795ea9b208..07c84bcde4fda 100644 --- a/polkadot/xcm/procedural/src/builder_pattern.rs +++ b/polkadot/xcm/procedural/src/builder_pattern.rs @@ -92,7 +92,7 @@ fn generate_builder_raw_impl(name: &Ident, data_enum: &DataEnum) -> TokenStream2 let method = match &variant.fields { Fields::Unit => { quote! { - pub fn #method_name(mut self) -> Self { + pub fn #method_name(&mut self) -> &mut Self { self.instructions.push(#name::::#variant_name); self } @@ -107,7 +107,7 @@ fn generate_builder_raw_impl(name: &Ident, data_enum: &DataEnum) -> TokenStream2 .collect(); let arg_types: Vec<_> = fields.unnamed.iter().map(|field| &field.ty).collect(); quote! { - pub fn #method_name(mut self, #(#arg_names: #arg_types),*) -> Self { + pub fn #method_name(&mut self, #(#arg_names: #arg_types),*) -> &mut Self { self.instructions.push(#name::::#variant_name(#(#arg_names),*)); self } @@ -117,7 +117,7 @@ fn generate_builder_raw_impl(name: &Ident, data_enum: &DataEnum) -> TokenStream2 let arg_names: Vec<_> = fields.named.iter().map(|field| &field.ident).collect(); let arg_types: Vec<_> = fields.named.iter().map(|field| &field.ty).collect(); quote! { - pub fn #method_name(mut self, #(#arg_names: #arg_types),*) -> Self { + pub fn #method_name(&mut self, #(#arg_names: #arg_types),*) -> &mut Self { self.instructions.push(#name::::#variant_name { #(#arg_names),* }); self }