Description
In order to be able to upgrade the syn dependency of the rust-cpp crate ( mystor/rust-cpp#41 ), one would need to be able to extract the raw source code for a given TokenTree (or a Span)
One could do that, I guess, by using TokenTree::span, and then getting the start/end and source_file of the span. But these function are "semver exempt". Even if they were not, that would mean we would need to recompute the offset in the file from line/column, which would be inefficient.
So what would be nice would be an start_offset and end_offset within Span.
Or better, a function that would return a String or a &str with the exact spelling.
TokenStream::to_string() does not work, as it adds spaces between token (that makes the resulting string invalid C++ as the two languages don't have the same grammar).
This is useful for crates, like rust-cpp, that allow to embed arbitrary languages within a rust macro (as long as the [], () and {} are balanced))