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

move all_zeroes & from_byte_array to inherents & make them const. #2641

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

15IITian
Copy link
Contributor

Made these functions const fn & move them from the Hash trait to hash_type & hash_newtype macros

fix #2377

@github-actions github-actions bot added C-bitcoin PRs modifying the bitcoin crate C-hashes PRs modifying the hashes crate labels Mar 30, 2024
@coveralls
Copy link

coveralls commented Mar 30, 2024

Pull Request Test Coverage Report for Build 8583563910

Details

  • 29 of 30 (96.67%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 83.137%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bitcoin/src/blockdata/constants.rs 5 6 83.33%
Totals Coverage Status
Change from base Build 8573430294: 0.02%
Covered Lines: 19188
Relevant Lines: 23080

💛 - Coveralls

@apoelstra
Copy link
Member

1d6373d looks good to me other than the grammar thing.

Also, the CI failure is minor but real -- please remove the now-unused Hash import from the example.

@15IITian
Copy link
Contributor Author

@15IITian
Copy link
Contributor Author

15IITian commented Mar 30, 2024

Recently noticed -> our code is not formatted according to rust fmt tool (cargo fmt).

@tcharding
Copy link
Member

Thanks for the PR, this is not a refactor, its an API breaking change because it removes functions from a public trait. I always link contributors to https://chris.beams.io/posts/git-commit/ (also mentioned in CONTRIBUTING.md). If a dev describes why we should have a change, and what the change is then it clarifies a bunch of things, including that:

  • dev understands fully the change (the why and the what)
  • reviewer can understand the context

I don't think you would have written "refactor" after writing a why/what PR description for the changes in this PR :)

@tcharding
Copy link
Member

Converting to draft because we are in a feature freeze right now, this needs to wait until rust-bitcoin 0.32.0 is out.

@tcharding tcharding marked this pull request as draft March 31, 2024 00:28
@15IITian
Copy link
Contributor Author

this is not a refactor, its an API breaking change because it removes functions from a public trait

Well ,I agree that it is more often a api breaking change but while writting conventional commit ->I could'nt find more relevant tag than 'refactor' -> A code change that neither fixes a bug nor adds a feature :)

I always link contributors to https://chris.beams.io/posts/git-commit/ (also mentioned in CONTRIBUTING.md)

👍

@tcharding
Copy link
Member

"Refactor" is a well defined term:

In computer programming and software design, code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.

ref: https://en.wikipedia.org/wiki/Code_refactoring.

We don't enforce any particular format of git brief messages, so there is no requirement to put any sort of tag at the start of the message. Just something simple like "Use inherent functions instead of trait methods" would be fine.

Thanks

Made these functions const fn & move them from the `Hash` trait to `hash_type` & `hash_newtype`
macros

fix rust-bitcoin#2377
@15IITian 15IITian changed the title refactor: move all_zeroes & from_byte_array to inherents & make them const. move all_zeroes & from_byte_array to inherents & make them const. Apr 6, 2024
@tcharding
Copy link
Member

Feature freeze is over man, you are free to push this up if you want to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bitcoin PRs modifying the bitcoin crate C-hashes PRs modifying the hashes crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

const constructors for hashes
4 participants