diff --git a/crates/fce-test-macro-impl/src/fce_test/glue_code_generator.rs b/crates/fce-test-macro-impl/src/fce_test/glue_code_generator.rs index 3ec6b52..0f32669 100644 --- a/crates/fce-test-macro-impl/src/fce_test/glue_code_generator.rs +++ b/crates/fce-test-macro-impl/src/fce_test/glue_code_generator.rs @@ -122,7 +122,7 @@ pub(super) fn generate_test_glue_code( #app_service_ctor - #module_ctors + #(#module_ctors)* #original_block } @@ -157,22 +157,19 @@ fn generate_app_service_ctor(config_path: &str, modules_dir: &PathBuf) -> TokenS fn generate_module_ctors<'n>( module_names: impl ExactSizeIterator, -) -> TResult { - let mut module_ctors = Vec::with_capacity(module_names.len()); - for name in module_names { - // TODO: optimize these two call because they are called twice for each module name - // and internally allocate memory in format call. - let module_name = fce_test::utils::generate_module_name(&name)?; - let struct_name = fce_test::utils::generate_struct_name(&name)?; - let name_for_user = fce_test::utils::new_ident(&name)?; +) -> TResult> { + module_names + .map(|name| -> TResult<_> { + // TODO: optimize these two call because they are called twice for each module name + // and internally allocate memory in format call. + let module_name = fce_test::utils::generate_module_name(&name)?; + let struct_name = fce_test::utils::generate_struct_name(&name)?; + let name_for_user = fce_test::utils::new_ident(&name)?; - let module_ctor = - quote! { let mut #name_for_user = #module_name::#struct_name::new(fce.clone()); }; + let module_ctor = + quote! { let mut #name_for_user = #module_name::#struct_name::new(fce.clone()); }; - module_ctors.push(module_ctor); - } - - let module_ctors = quote! { #(#module_ctors),* }; - - Ok(module_ctors) + Ok(module_ctor) + }) + .collect::>() } diff --git a/crates/fce-test-macro-impl/src/fce_test/module_generator/methods_generator.rs b/crates/fce-test-macro-impl/src/fce_test/module_generator/methods_generator.rs index 58a4288..7d6ac63 100644 --- a/crates/fce-test-macro-impl/src/fce_test/module_generator/methods_generator.rs +++ b/crates/fce-test-macro-impl/src/fce_test/module_generator/methods_generator.rs @@ -31,7 +31,7 @@ pub(super) fn generate_module_methods<'m, 'r>( records: &'r FCERecordTypes, ) -> TResult> { method_signatures - .map(|signature| -> TResult { + .map(|signature| -> TResult<_> { let func_name = utils::new_ident(&signature.name)?; let arguments = generate_arguments(signature.arguments.iter(), records)?; let output_type = generate_output_type(&signature.outputs, records)?; @@ -45,7 +45,7 @@ pub(super) fn generate_module_methods<'m, 'r>( Ok(module_method) }) - .collect::, _>>() + .collect::>>() } fn generate_fce_call( @@ -128,16 +128,15 @@ fn generate_arguments<'a, 'r>( arguments: impl ExactSizeIterator, records: &'r FCERecordTypes, ) -> TResult> { - let mut result = Vec::with_capacity(arguments.len()); - for argument in arguments { - let arg_name = utils::new_ident(&argument.name)?; - let arg_type = utils::itype_to_tokens(&argument.ty, records)?; + arguments + .map(|argument| -> TResult<_> { + let arg_name = utils::new_ident(&argument.name)?; + let arg_type = utils::itype_to_tokens(&argument.ty, records)?; - let arg = quote! { #arg_name: #arg_type }; - result.push(arg); - } - - Ok(result) + let arg = quote! { #arg_name: #arg_type }; + Ok(arg) + }) + .collect::>>() } fn generate_output_type(output_types: &[IType], records: &FCERecordTypes) -> TResult { diff --git a/crates/fce-test-macro-impl/src/fce_test/module_generator/record_type_generator.rs b/crates/fce-test-macro-impl/src/fce_test/module_generator/record_type_generator.rs index 32bd833..2e20dfd 100644 --- a/crates/fce-test-macro-impl/src/fce_test/module_generator/record_type_generator.rs +++ b/crates/fce-test-macro-impl/src/fce_test/module_generator/record_type_generator.rs @@ -26,7 +26,7 @@ use quote::quote; pub(super) fn generate_records(records: &FCERecordTypes) -> TResult> { use std::ops::Deref; - records.iter().map(|(_, record)| -> TResult { + records.iter().map(|(_, record)| -> TResult<_> { let record_name_ident = utils::generate_record_name(&record.name)?; let fields = prepare_field(record.fields.deref().iter(), records)?; @@ -39,7 +39,7 @@ pub(super) fn generate_records(records: &FCERecordTypes) -> TResult, _>>() + ).collect::>>() } fn prepare_field<'f>( @@ -47,7 +47,7 @@ fn prepare_field<'f>( records: &FCERecordTypes, ) -> TResult> { fields - .map(|field| -> TResult { + .map(|field| -> TResult<_> { let field_name = utils::new_ident(&field.name)?; let field_type = utils::itype_to_tokens(&field.ty, records)?; @@ -55,5 +55,5 @@ fn prepare_field<'f>( Ok(generated_field) }) - .collect::, _>>() + .collect::>>() } diff --git a/crates/fce-test-macro-impl/src/lib.rs b/crates/fce-test-macro-impl/src/lib.rs index 51f196e..432d957 100644 --- a/crates/fce-test-macro-impl/src/lib.rs +++ b/crates/fce-test-macro-impl/src/lib.rs @@ -14,7 +14,6 @@ * limitations under the License. */ -#![doc(html_root_url = "https://docs.rs/fluence-sdk-macro/0.5.0")] #![deny( dead_code, nonstandard_style, diff --git a/fluence-test/src/lib.rs b/fluence-test/src/lib.rs index 278355f..c60b3fc 100644 --- a/fluence-test/src/lib.rs +++ b/fluence-test/src/lib.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -#![doc(html_root_url = "https://docs.rs/fluence/0.5.0")] +#![doc(html_root_url = "https://docs.rs/fluence-test/0.5.0")] #![deny( dead_code, nonstandard_style,