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

Add Iterator traits #75

Merged
merged 46 commits into from
Feb 27, 2022
Merged

Add Iterator traits #75

merged 46 commits into from
Feb 27, 2022

Conversation

rye
Copy link
Owner

@rye rye commented Jan 9, 2020

Closes #74.

Draft-to-Final Checklist

  • Implement AddressIterator<N, A> generic and provide impls on Net.*Addr types.
  • Implement SubnetIterator<N, A> generic and provide impls on Net.*Addr types.
  • Ensure corner cases (boundaries, minimum and maximum values) are properly handled
  • Remove panic paths, use error handling primitives.

Acceptance criteria

@codecov
Copy link

codecov bot commented Jan 9, 2020

Codecov Report

Merging #75 (111b9e5) into main (ac96adc) will increase coverage by 0.11%.
The diff coverage is 98.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
+ Coverage   97.88%   98.00%   +0.11%     
==========================================
  Files          46       49       +3     
  Lines        1610     2155     +545     
==========================================
+ Hits         1576     2112     +536     
- Misses         34       43       +9     
Impacted Files Coverage Δ
src/lib.rs 100.00% <ø> (ø)
src/iter/offset.rs 97.36% <97.36%> (ø)
src/iter/subnet.rs 97.64% <97.64%> (ø)
src/iter/address.rs 100.00% <100.00%> (ø)
src/netaddr.rs 100.00% <100.00%> (ø)
src/netv4addr.rs 100.00% <100.00%> (ø)
src/netv4addr/contains.rs 100.00% <100.00%> (ø)
src/netv6addr.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac96adc...111b9e5. Read the comment docs.

rye added 27 commits January 5, 2022 07:02
Of course, I'll probably move stuff around, but this works.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
(I should probably use a generic...)

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
It turns out that it is easy to prevent overflow if we do this.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Tests coming soon.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
It'd be nice to have some random tests to verify that nothing
breaks... we'll see about that.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
This is far cleaner!  And more expandible!

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Rather than unwrapping and rewrapping shortly thereafter, we can just
call .ok() to transform the Result<T, E> from parsing into an
Option<T>, which is guaranteed to be T=IpAddr as we want it.

This lets all these things sit on one line, which is also nice.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Generic across the entire conceivable set of types, in fact!

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
This is slightly more aligned with what the trait does.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
This is apparently a short enough name to work properly!  Yippee.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
This method _always_ returns `false`, since a network is never empty.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
(This method always returns zero, since log(0) is undefined.)

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
rye added 13 commits January 5, 2022 07:05
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Tested-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
@rye rye marked this pull request as ready for review February 25, 2022 13:06
@rye rye self-assigned this Feb 25, 2022
@rye rye added the enhancement New feature or request label Feb 25, 2022
@rye rye merged commit 30ab1fc into main Feb 27, 2022
@rye rye deleted the iteration branch February 27, 2022 19:17
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
None yet
Development

Successfully merging this pull request may close these issues.

Implement Iterator-y traits
1 participant