-
Notifications
You must be signed in to change notification settings - Fork 39
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
Migrate to 8.0 nom
#96
Conversation
@progval ready for review 🫡 |
LGTM, but I haven't looked at this code in a while. So I wouldn't mind an extra review from @duncanawoods since they did similar work in #98 |
Thanks to @duncanawoods (#98)
I've closed my version. Our code change looks identical only differing by how we renamed the slice function (slice_by vs. slice_with lol). I hadn't updated the doc code though. I had created a helper trait to support slicing with ranges given how much code in the crate used that calling style. My main motivation was just as a transition so I didn't break the tests before using them but an argument to include this would be that chaining take functions with duplicated indices feels a bit bug prone. Not necessary by any means, but if you want it, here it is: pub trait SliceInput {
fn slice(&self, range: impl RangeBounds<usize>) -> Self;
}
impl<I: Input> SliceInput for I {
fn slice(&self, range: impl RangeBounds<usize>) -> I {
let start = match range.start_bound() {
Bound::Included(&n) => n,
Bound::Excluded(&n) => n + 1,
Bound::Unbounded => 0,
};
let end = match range.end_bound() {
Bound::Included(&n) => n + 1,
Bound::Excluded(&n) => n,
Bound::Unbounded => self.input_len(),
};
if start == 0 {
self.take(end)
} else {
self.take_from(start).take(end - start)
}
}
} |
ping @progval |
thanks! |
Published as v5.0.0 |
Resolves #87
Resolves #97