Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support anonymous slice element. #30

Closed
crlf0710 opened this issue Jul 4, 2020 · 3 comments
Closed

Feature request: support anonymous slice element. #30

crlf0710 opened this issue Jul 4, 2020 · 3 comments

Comments

@crlf0710
Copy link

crlf0710 commented Jul 4, 2020

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
Copy link
Owner

dtolnay commented Jul 4, 2020

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

@dtolnay dtolnay closed this as completed Jul 4, 2020
@dtolnay
Copy link
Owner

dtolnay commented Jul 4, 2020

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

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

@crlf0710
Copy link
Author

crlf0710 commented Jul 5, 2020

OK, great to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants