dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
646 stars 41 forks source link

Feature request: support anonymous slice element. #30

Closed crlf0710 closed 4 years ago

crlf0710 commented 4 years ago

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).

dtolnay commented 4 years ago

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

dtolnay commented 4 years ago

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

const _: () = {
    #[distributed_slice(...)]
    static __: Type = value;
};
crlf0710 commented 4 years ago

OK, great to know, thanks!