Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my design/attempt at implementing #275
Proposed Syntax
I spent a lot of time thinking about what the syntax should be. IMO, it should:
#
to indicate interpolation)I started with
#{ ... }
, went though many iterations and in the end settled on#@{ ... }@
:#
to indicate start interpolating, which is consistent with other interpolation pattern@
and{}
are commonly used for interpolationProposed Behavior
There are 2 ways where this could be implemented, with different behaviors:
TokenStream
I chose 2 since the implementation is way simpler, and probably more intuitive when composed with
#( ... )*
. This implementation also allows the blocks to access the bindings generated by#( ... )*
, which becomes useful if we makeRepInterp
implementDeref
. Just a dummy example:Also, for ergonomic reasons, it's ideal for the macro to handle both when the block outputs a
ToTokens
or an iterator of them. This is implemented with a same trick used for repetition where ato_tokens
method shadows the trait method if the trait is not implementedOther
Deref
forRepInterp
?Please let me know if there are other concerns
Tasks