syn icon indicating copy to clipboard operation
syn copied to clipboard

Consider whether const generics supersedes the `Token!` macro

Open dtolnay opened this issue 2 years ago • 3 comments

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 avatar Dec 03 '22 23:12 dtolnay

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

dtolnay avatar Dec 03 '22 23:12 dtolnay

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

dtolnay avatar Dec 04 '22 00:12 dtolnay

Tracking issue: https://github.com/rust-lang/rust/issues/95174

dtolnay avatar Jan 16 '23 08:01 dtolnay