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

Codegen token-related functions and provide quote! as a lightweight proc-macro #137

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Oct 6, 2020

The new quote! macro doesn't make use of quote or syn parsing internally, and uses codegened lookup tables for keywords and punctuations. It's also not implemented as a macro_rules! as previously.

This accomplishes the following things:

  • The proc macro is as fast and uses as little resources as it can.
  • $ is a reserved punctuation in macro_rules!, so converting quote! into a proc macro allows us to use it.
  • quote! produces an instance of Quote<'a> that implements ToTokens, which is a stored environment that can perform the specified quoting. This avoids copying a token stream excessively when nesting quoting.

@udoprog udoprog added the enhancement New feature or request label Oct 6, 2020
@udoprog udoprog merged commit 4467cd4 into master Oct 6, 2020
@udoprog udoprog deleted the new-quote branch October 6, 2020 14:23
@udoprog udoprog added the changelog Issue has been added to the changelog label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant