Messages in this thread | | | Date | Mon, 14 Nov 2022 14:39:26 +0000 | From | Björn Roy Baron <> | Subject | Re: [PATCH v1 05/28] rust: macros: add `concat_idents!` proc macro |
| |
On Monday, November 14th, 2022 at 15:26, Gary Guo <gary@garyguo.net> wrote:
> 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
I agree that is clearer. I hadn't considered that Ident implements Display when I wrote it.
Cheers, Björn
| |