lkml.org 
[lkml]   [2023]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] rust: macros: update 'paste!' macro to accept string literals
On Sat, Nov 18, 2023 at 2:41 AM Trevor Gross <tmgross@umich.edu> wrote:
>
> Enable combining identifiers with literals in the 'paste!' macro. This
> allows combining user-specified strings with affixes to create
> namespaced identifiers.
>
> This sample code:
>
> macro_rules! m {
> ($name:lit) => {
> paste!(struct [<_some_ $name _struct_>] {})
> }
> }
>
> m!("foo_bar");
>
> Would previously cause a compilation error. It will now generate:
>
> struct _some_foo_bar_struct_ {}
>
> Signed-off-by: Trevor Gross <tmgross@umich.edu>
> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <benno.lossin@proton.me>
> Reviewed-by: Gary Guo <gary@garyguo.net>

Since there are no other replies to this version, I'll confirm that
this still looks good to me.

Alice

\
 
 \ /
  Last update: 2023-11-27 15:08    [W:2.606 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site