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

Audit error types #31

Merged
merged 3 commits into from
Oct 26, 2023
Merged

Audit error types #31

merged 3 commits into from
Oct 26, 2023

Conversation

tcharding
Copy link
Member

Audit the crate error types (all two of them) and ensure they follow the "standard" we are starting to settle on here in the rust-bitcoin org.

@tcharding tcharding mentioned this pull request Oct 25, 2023
@@ -117,7 +117,7 @@ impl<'a> fmt::UpperHex for DisplayALittleBitHexy<'a> {
}

/// Example Error.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
/// Conversion error while parsing hex string.
Conversion(HexToBytesError),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see InvalidStringFormat below used anywhere is it still needed?

@Kixunil
Copy link
Collaborator

Kixunil commented Oct 25, 2023

As for ordering Copy/Clone do we have a standard order now? For me Copy is mentally more important since Clone is implied, so previous order makes more sense (and I write it int that order) but I guess this is too much bikeshedding.

@tcharding
Copy link
Member Author

As for ordering Copy/Clone do we have a standard order now? For me Copy is mentally more important since Clone is implied, so previous order makes more sense (and I write it int that order) but I guess this is too much bikeshedding.

Drats, I wish you were here a few months ago, I've made this change in so many places. I agree with you (on the ordering not the too much bikeshedding :) - FWIW when trying to come up with an order I went with Copy depends on Clone being there so put it after, I like yours better though.

You owe me one, for the shitstorm I'm going to get when I patch the whole org one Friday afternoon with this change.

@apoelstra
Copy link
Member

You owe me one, for the shitstorm I'm going to get when I patch the whole org one Friday afternoon with this change.

Lol! FWIW I really don't think it matters as long as they're beside each other.

@tcharding
Copy link
Member Author

This is a text book case of "just have one way of doing it and do it like that ... for ever". Maybe I'm too stuck on this principle and too easily triggered, we all have weaknesses eh.

@tcharding
Copy link
Member Author

Needs #33 to get past CI

We are slowly settling on a few standards for error types, one of which
is a standard set of derives. The errors in this crate are
non-exhaustive so we should use: `Debug, Copy, Clone, PartialEq, Eq`.
Error conversion `from` can be inlined, it is a trivial wrap.
Remove the unnecessary `self::` from local use statement.
@Kixunil
Copy link
Collaborator

Kixunil commented Oct 26, 2023

Yeah, not worth reverting, I was just curious about it.

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 9d851d4

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 9d851d4

@apoelstra apoelstra merged commit 2e25d6c into rust-bitcoin:master Oct 26, 2023
9 checks passed
@tcharding tcharding deleted the 10-25-errors branch October 27, 2023 01:44
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.

3 participants