lkml.org 
[lkml]   [2022]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 05/28] rust: macros: add `concat_idents!` proc macro
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

\
 
 \ /
  Last update: 2022-11-14 15:28    [W:0.386 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site