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

Consider whether const generics supersedes the Token! macro #1252

Open
dtolnay opened this issue Dec 3, 2022 · 3 comments
Open

Consider whether const generics supersedes the Token! macro #1252

dtolnay opened this issue Dec 3, 2022 · 3 comments
Labels

Comments

@dtolnay
Copy link
Owner

dtolnay commented Dec 3, 2022

Something like:

pub struct Token<const A: char, const B: char = '\0', const C: char = '\0'>;

Then you'd use Token<'+'> for what used to be Token![+], and Token<'+', '='> instead of Token![+=], etc.

The custom_punctuation! macro (https://docs.rs/syn/1.0.105/syn/macro.custom_punctuation.html) would no longer be necessary because you could instantiate a Token with any arbitrary punctuation without needing to give it a name.

@dtolnay
Copy link
Owner Author

dtolnay commented Dec 3, 2022

Another possibility: the approach from https://docs.rs/monostate/0.1.1/monostate/index.html.

@dtolnay
Copy link
Owner Author

dtolnay commented Dec 4, 2022

See #1209. The use of type macros like Token! in a generic data structure prevents derive from being used.

@dtolnay
Copy link
Owner Author

dtolnay commented Jan 16, 2023

Tracking issue: rust-lang/rust#95174

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

No branches or pull requests

1 participant