From f99dbd21cf9023cd419eebea3991b60c6565bc24 Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Tue, 23 Apr 2024 16:59:02 +0000 Subject: [PATCH] format_ident! is much nicer than string concat --- pyo3-testing/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyo3-testing/src/lib.rs b/pyo3-testing/src/lib.rs index 5304fb8814f..b3a16bf065b 100644 --- a/pyo3-testing/src/lib.rs +++ b/pyo3-testing/src/lib.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use proc_macro::TokenStream as TokenStream1; use proc_macro2::{Span, TokenStream as TokenStream2}; -use quote::ToTokens; +use quote::{format_ident, ToTokens}; use syn::{ parse::{Parse, ParseStream}, parse2, parse_quote, @@ -187,10 +187,7 @@ fn wrap_testcase(mut testcase: Pyo3TestCase) -> TokenStream2 { py_ModuleNotFoundErrormsgs.push("Failed to import ".to_string() + &py_modulename); py_moduleidents.push(Ident::new(&py_modulename, Span::call_site())); py_modulenames.push(py_modulename); - o3_pymoduleidents.push(Ident::new( - &("".to_string() + &pyo3import.o3_moduleident.to_string() + "_pymodule"), - Span::call_site(), - )); + o3_pymoduleidents.push(format_ident!("{}_pymodule", pyo3import.o3_moduleident)); o3_moduleidents.push(pyo3import.o3_moduleident); }