dtolnay/linkme

Feature request: support anonymous slice element.

Closed this issue · 3 comments

I'm trying to write a macro that put elements into a distribute_slice. One hard thing is that i have to name the individual items...

I feel it would be more convenient if using _ as the name of anonymous slice element is supported (distribute_slice(XYZ) can replace it with whatever name it feels best i think).

This would be on the language to permit static _ as valid syntax; it was decided against in rust-lang/rust#54912.

To avoid naming elements from the macro you can make your macro expand to:

const _: () = {
    #[distributed_slice(...)]
    static __: Type = value;
};

OK, great to know, thanks!