You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often find myself reaching for pest::span::Span to keep a mapping back to the parsed source file. I sometimes run into issues because Span::input is not pub.
I'd like to propose adding two methods to Span to give it more flexibility for users:
I often find myself reaching for
pest::span::Span
to keep a mapping back to the parsed source file. I sometimes run into issues becauseSpan::input
is notpub
.I'd like to propose adding two methods to
Span
to give it more flexibility for users:pub fn sub_span(&self, range: impl std::ops::RangeBounds<usize>) -> Option<Span>
Span
, returning a smaller span (or "substring") which preserves the originalSpan
's input.pub fn lines_span(&self) -> LinesSpan
LinesSpan
is an iterator, much likepest::span::Lines
, but returnsSpan
instead of&str
.Lines
can be implemented asspan.lines_span().map(|span| span.start_pos().line_of())
I've created a draft PR with a more concrete example of this proposal: #456.
Thanks for your time!
The text was updated successfully, but these errors were encountered: