Re: [PATCH v1 05/28] rust: macros: add `concat_idents!` proc macro

Gary Guo
2022-11-14T14:26:25Z

On Thu, 10 Nov 2022 17:41:17 +0100
Miguel Ojeda <ojeda@kernel.org> wrote:

> +pub(crate) fn concat_idents(ts: TokenStream) -> TokenStream {
> + let mut it = ts.into_iter();
> + let a = expect_ident(&mut it);
> + assert_eq!(expect_punct(&mut it), ',');
> + let b = expect_ident(&mut it);
> + assert!(it.next().is_none(), "only two idents can be concatenated");
> + let res = Ident::new(&(a.to_string() + &b.to_string()), b.span());

Probably clearer to write `Ident::new(&format!("{a}{b}"), b.span())`
here?

Best,
Gary