rust-bitcoin / bitcoin_hashes

Simple library which implements a few hashes and does nothing else
Creative Commons Zero v1.0 Universal
66 stars 52 forks source link

Use SliceIndex trait to implement Index #142

Closed tcharding closed 2 years ago

tcharding commented 2 years ago

Since we bumped to Rust 1.29 it has not been necessary to implement Index manually, we can get it by way of the SliceIndex trait.

Implement Index using SliceIndex. Keep the declarative macro so we only have to write the SliceIndex implementation once.

This is in the same vein as https://github.com/rust-bitcoin/rust-bitcoin/pull/805 but goes about it in a slightly different manner, we should probably be uniform across both crates. I'm unsure which is the best option?

apoelstra commented 2 years ago

I think, now that we have SliceIndex, we could just inline this and drop the macro entirely. It's a bit duplicative but not nearly as bad as the 1.0-era "implement four different Index traits" code.

apoelstra commented 2 years ago

BTW - this is a breaking change because we exported this macro and downstream users may have been using it :(

tcharding commented 2 years ago

Do we need to add a label to this to remind us we broke the API?

apoelstra commented 2 years ago

I think it'll be okay -- we'll go over all the merged PRs when making the changelog for the next release.