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

Implement RangeEnd, Range #19

Merged
merged 4 commits into from
Jun 21, 2024
Merged

Implement RangeEnd, Range #19

merged 4 commits into from
Jun 21, 2024

Conversation

sgwilym
Copy link
Contributor

@sgwilym sgwilym commented Jun 21, 2024

Implements Willow’s one-dimensional ‘range’ grouping as described here, with testing for value inclusion, range inclusion, intersection creation, and a method which creates a range including all values of that type.

While it's still possible to create empty ranges by initialising a Range directly, attempting to do so with new_closed will return a EmptyRangeError.

This is a draft while I add some fuzzing tests, but I think the implementation is ready to look at!

Implements Willow’s one-dimensional ‘range’ grouping as described here: https://willowprotocol.org/specs/grouping-entries/index.html#range
@sgwilym sgwilym added the enhancement New feature or request label Jun 21, 2024
@Frando
Copy link
Contributor

Frando commented Jun 21, 2024

Looks good! And cool that my code from iroh-willow is of direct use here :-)

@sgwilym sgwilym marked this pull request as ready for review June 21, 2024 11:29
@AljoschaMeyer
Copy link
Contributor

AljoschaMeyer commented Jun 21, 2024

Btw, I think that all functions that deal with potentially empty ranges should either use Option or Result<Range, RangeError>, but no mixture (currently, intersecting yields an Option, but closed creation a Result).

@sgwilym
Copy link
Contributor Author

sgwilym commented Jun 21, 2024

@AljoschaMeyer sure. I think it makes more sense for creation to be an Option than to make non-intersection return an error, on it.

@sgwilym sgwilym merged commit 2af43cd into main Jun 21, 2024
1 check passed
@sgwilym sgwilym deleted the grouping-range branch June 23, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

3 participants