Skip to content

Commit

Permalink
segwit: Rename EncodeError::Write variant to Fmt
Browse files Browse the repository at this point in the history
Its cleaner if both the `lib.rs` `EncodeError` and the
`segwit::EncodeError` use variants named uniformly.

In preparation for adding `Write` and `Fmt` variants (for
`std::io::Write` and `fmt::Write` respectively) to the `EncodeError` in
`lib.rs` rename the current `EncodeError::Write(fmt::Error)` variant to
`Fmt`.
  • Loading branch information
tcharding committed Oct 17, 2023
1 parent ed46a10 commit 6dc73c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/segwit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ pub enum EncodeError {
/// Encoding HRP, witver, and program into a bech32 string exceeds limit of 90 characters.
TooLong(EncodedLengthError),
/// Writing to formatter failed.
Write(fmt::Error),
Fmt(fmt::Error),
}

impl fmt::Display for EncodeError {
Expand All @@ -392,7 +392,7 @@ impl fmt::Display for EncodeError {
WitnessVersion(ref e) => write_err!(f, "witness version"; e),
WitnessLength(ref e) => write_err!(f, "witness length"; e),
TooLong(ref e) => write_err!(f, "encoded string too long"; e),
Write(ref e) => write_err!(f, "writing to formatter failed"; e),
Fmt(ref e) => write_err!(f, "writing to formatter failed"; e),
}
}
}
Expand All @@ -406,7 +406,7 @@ impl std::error::Error for EncodeError {
WitnessVersion(ref e) => Some(e),
WitnessLength(ref e) => Some(e),
TooLong(ref e) => Some(e),
Write(ref e) => Some(e),
Fmt(ref e) => Some(e),
}
}
}
Expand All @@ -428,7 +428,7 @@ impl From<EncodedLengthError> for EncodeError {

impl From<fmt::Error> for EncodeError {
#[inline]
fn from(e: fmt::Error) -> Self { Self::Write(e) }
fn from(e: fmt::Error) -> Self { Self::Fmt(e) }
}

#[cfg(all(test, feature = "alloc"))]
Expand Down

0 comments on commit 6dc73c8

Please sign in to comment.