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 must_use for mut self key manipulation methods #465

Merged
merged 2 commits into from Jun 28, 2022

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Jun 28, 2022

We recently added a bunch of key tweaking methods that take mut self
and return the tweaked/negated keys. These functions are pure and as
such the returned result is expected to be used. To help downstream
users use the API correctly add must_use attributes with a descriptive
error string for each of the methods that takes mut self.

Patch 1 is preparatory cleanup.

It is conventional, at least within the `rust-bitcoin` organisation to
put compiler attributes _below_ the associated rustdocs.
We recently added a bunch of key tweaking methods that take `mut self`
and return the tweaked/negated keys. These functions are pure and as
such the returned result is expected to be used. To help downstream
users use the API correctly add `must_use` attributes with a descriptive
error string for each of the methods that takes `mut self`.
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 56f1843

@apoelstra apoelstra merged commit 5f59820 into rust-bitcoin:master Jun 28, 2022
@tcharding tcharding deleted the 06-28-must-use-mut-self branch June 29, 2022 00:50
@Kixunil
Copy link
Collaborator

Kixunil commented Jul 8, 2022

Uh, these are useless on fns returning Result

@apoelstra
Copy link
Member

Oh, lol, right. Result is already #[must_use] and the intended goal (adding #[must_use] on the value contained i the Result) is not obviously possible.

@tcharding
Copy link
Member Author

Drats, will remove the changes. Thanks

@tcharding
Copy link
Member Author

FTR, done in: #472

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post merge ACK 56f1843

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 this pull request may close these issues.

None yet

4 participants