-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Implement Span::sub_span
and Span::lines_span
.
#456
Conversation
This looks reasonable to me at a glance. @dragostis ? |
Some concerns I have (that may not actually be real issues):
|
I am also interested in |
There are similar requests for additional flexibility ( such as #469 ). There are other types that provide flexibility such as ErrorVariant::CustomError. Subspans could be similarly useful.
I prefer
@tomtau is this PR blocked waiting for better documentation? |
@Alextopher unless @tangmi plans to revive this PR soon, yes, I think two main items to fix will be to adjust the docs a little bit (to provide a full example usage) and to resolve a minor conflict with the latest target branch. |
let start = match range.start_bound() { | ||
std::ops::Bound::Included(&offset) => offset, | ||
std::ops::Bound::Excluded(&offset) => offset + 1, | ||
std::ops::Bound::Unbounded => 0, | ||
}; | ||
let end = match range.end_bound() { | ||
std::ops::Bound::Included(&offset) => Some(offset + 1), | ||
std::ops::Bound::Excluded(&offset) => Some(offset), | ||
std::ops::Bound::Unbounded => None, | ||
}; | ||
let s = self.as_str(); | ||
if s.get(start..end.unwrap_or(s.len())).is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alextopher one more item to fix: the merge conflict seems to be about core
vs std
. pest now supports no_std
, so these ops
may either need to be adjusted for no_std
or sub_span should be feature-guarded for std
Some(unsafe { | ||
Span::new_unchecked(self.span.input, line_start, self.pos.min(self.span.end)) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alextopher could this be done without unsafe
? if not, it should have a Safety
comment explaining why it is safe or when things could go wrong
Sounds good. I started by creating a new PR with just |
closing in favour of #681 |
Prototype implementation for #455