syn
syn copied to clipboard
Ability to map subspans of a `LitStr` into subspans of the backing `Literal`
In order to create accurate subspans into a LitStr
there needs to be some way to map offsets from the string value into offsets of the Literal
. As an example for the literal r#"\x7Ba}"
the string value is {a}
, the a
character has the range 1..2
which has to be mapped to 7..8
, or the {
character has the range 0..1
which has to be mapped to 3..7
.
#621 is tangentially related, but that only applies if the literal is parsed through syn::Parse
. If instead the string value is being parsed via another parser that is able to give back subranges those need to be manually mapped somehow.