dtolnay / paste

Macros for all your token pasting needs
Apache License 2.0
1.02k stars 56 forks source link

Lifetime idents support #89

Closed tqwewe closed 1 year ago

tqwewe commented 1 year ago

Is it possible to create lifetimes with paste?

For example:

macro_rules! impl_types {
    ( $($ty:ident),* ) => {
        paste::paste! {
            impl<$( '[< $ty >], $ty ),*> … { … }
        }
    }
}
dtolnay commented 1 year ago

It should work as long as you put the ' inside the [<. impl<$([<'_ $ty>],)* $($ty,)*> ….

tqwewe commented 1 year ago

Ah okay, it also seems like I have to do [< '_ $ty >] instead of just [< ' $ty >]

dtolnay commented 1 year ago

[< ' $ty >] is not lexically valid Rust tokens so rustc wouldn't allow that in macro input.

If you don't want an underscore in the lifetime then you can use [<"'" $ty>].