Skip to content
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

Merged
merged 6 commits into from
Feb 3, 2025
Merged

Migrate to 8.0 nom #96

merged 6 commits into from
Feb 3, 2025

Conversation

tyranron
Copy link
Contributor

@tyranron tyranron commented Jan 28, 2025

Resolves #87
Resolves #97

@progval progval mentioned this pull request Jan 28, 2025
@progval progval mentioned this pull request Jan 28, 2025
@tyranron
Copy link
Contributor Author

@progval ready for review 🫡

@progval
Copy link
Collaborator

progval commented Jan 28, 2025

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

@duncanawoods
Copy link

Hi @tyranron @progval

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)
        }
    }
}

@tyranron
Copy link
Contributor Author

tyranron commented Feb 3, 2025

ping @progval

@progval
Copy link
Collaborator

progval commented Feb 3, 2025

thanks!

@progval progval merged commit e02c099 into fflorent:master Feb 3, 2025
13 checks passed
@progval
Copy link
Collaborator

progval commented Feb 3, 2025

Published as v5.0.0

@tyranron tyranron deleted the nom-8.0 branch February 3, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to nom v8.0 Upcoming breaking changes for input types in nom
3 participants