Skip to content

Commit

Permalink
Merge #31: Audit error types
Browse files Browse the repository at this point in the history
9d851d4 Remove unnecessary self from use statement (Tobin C. Harding)
0605d44 Inline From impl for error type (Tobin C. Harding)
e59c211 Remove derives from error types (Tobin C. Harding)

Pull request description:

  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.

ACKs for top commit:
  Kixunil:
    ACK 9d851d4
  apoelstra:
    ACK 9d851d4

Tree-SHA512: be0ceb3f40c89271b4c5e99b46cf4bb1b12f11e646bcb21e4a05a2a3b0fbd244f07dae5c0b95b25cffd4d062d30ff97fa4b53d85b3364183b19ec45d68d2c5f5
  • Loading branch information
apoelstra committed Oct 26, 2023
2 parents 62a9be0 + 9d851d4 commit 2e25d6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a> fmt::UpperHex for DisplayALittleBitHexy<'a> {
}

/// Example Error.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Error {
/// Conversion error while parsing hex string.
Conversion(HexToBytesError),
Expand Down
9 changes: 5 additions & 4 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl FromHex for Vec<u8> {
}

/// Hex decoding error.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum HexToBytesError {
/// Non-hexadecimal character.
InvalidChar(u8),
Expand All @@ -48,7 +48,7 @@ pub enum HexToBytesError {

impl fmt::Display for HexToBytesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::HexToBytesError::*;
use HexToBytesError::*;

match *self {
InvalidChar(ch) => write!(f, "invalid hex character {}", ch),
Expand All @@ -60,7 +60,7 @@ impl fmt::Display for HexToBytesError {
#[cfg(feature = "std")]
impl std::error::Error for HexToBytesError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::HexToBytesError::*;
use HexToBytesError::*;

match self {
InvalidChar(_) | OddLengthString(_) => None,
Expand Down Expand Up @@ -114,7 +114,7 @@ impl_fromhex_array!(384);
impl_fromhex_array!(512);

/// Hex decoding error.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum HexToArrayError {
/// Conversion error while parsing hex string.
Conversion(HexToBytesError),
Expand Down Expand Up @@ -147,6 +147,7 @@ impl std::error::Error for HexToArrayError {
}

impl From<HexToBytesError> for HexToArrayError {
#[inline]
fn from(e: HexToBytesError) -> Self { Self::Conversion(e) }
}

Expand Down

0 comments on commit 2e25d6c

Please sign in to comment.