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 nth and nth_back #14

Open
tcharding opened this issue May 25, 2023 · 3 comments
Open

Implement nth and nth_back #14

tcharding opened this issue May 25, 2023 · 3 comments

Comments

@tcharding
Copy link
Member

tcharding commented May 25, 2023

Override the default implementations for the iterators in this crate.

This is an optimization thing not a functionality thing, see comments below where its explained.

tcharding added a commit to tcharding/hex-conservative that referenced this issue Oct 25, 2023
Add some unit tests to prove that the default implementation of `nth`
works correctly for `HexToBytesIter` and `BytesToHexIter`.

Resolve: rust-bitcoin#14
@tcharding
Copy link
Member Author

Don't know what I was thinking when I wrote this:

  • There is no such thing as nth_back.
  • The default nth works just fine.

I added some unit tests in #32 just to be sure.

tcharding added a commit to tcharding/hex-conservative that referenced this issue Oct 25, 2023
Add some unit tests to prove that the default implementation of `nth`
works correctly for `HexToBytesIter` and `BytesToHexIter`.

Resolve: rust-bitcoin#14
tcharding added a commit to tcharding/hex-conservative that referenced this issue Oct 25, 2023
Add some unit tests to prove that the default implementation of `nth`
works correctly for `HexToBytesIter` and `BytesToHexIter`.

Resolve: rust-bitcoin#14
@Kixunil
Copy link
Collaborator

Kixunil commented Oct 25, 2023

Overriding is good for performance if we can seek in O(1) since nth is O(n). For nth_back check DoubleEndedIterator.

tcharding added a commit to tcharding/hex-conservative that referenced this issue Oct 25, 2023
Add some unit tests to prove that the default implementation of `nth`
works correctly for `HexToBytesIter` and `BytesToHexIter`.

Resolve: rust-bitcoin#14
tcharding added a commit to tcharding/hex-conservative that referenced this issue Oct 25, 2023
Add some unit tests to prove that the default implementation of `nth`
works correctly for `HexToBytesIter` and `BytesToHexIter`.

Resolve: rust-bitcoin#14
@tcharding
Copy link
Member Author

ooooo, nice. Thanks man, so I should have put more context in the issue in the first place. Thanks!

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 a pull request may close this issue.

2 participants