Replace catch-all match arms with specific ones

This commit is contained in:
Carl Dong 2018-08-21 01:42:12 -07:00
parent 0c172941af
commit bccdd06794
3 changed files with 15 additions and 5 deletions

View File

@ -49,7 +49,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
Error::Io(ref e) => fmt::Display::fmt(e, f), Error::Io(ref e) => fmt::Display::fmt(e, f),
ref x => f.write_str(error::Error::description(x)), Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => f.write_str(error::Error::description(self)),
} }
} }
} }
@ -58,7 +58,7 @@ impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&error::Error> {
match *self { match *self {
Error::Io(ref e) => Some(e), Error::Io(ref e) => Some(e),
_ => None Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => None,
} }
} }

View File

@ -105,7 +105,15 @@ impl error::Error for Error {
Error::Base58(ref e) => Some(e), Error::Base58(ref e) => Some(e),
Error::Bech32(ref e) => Some(e), Error::Bech32(ref e) => Some(e),
Error::ByteOrder(ref e) => Some(e), Error::ByteOrder(ref e) => Some(e),
_ => None Error::UnexpectedNetworkMagic { .. }
| Error::OversizedVectorAllocation { .. }
| Error::InvalidChecksum { .. }
| Error::UnknownNetworkMagic(..)
| Error::ParseFailed(..)
| Error::UnsupportedWitnessVersion(..)
| Error::UnsupportedSegwitFlag(..)
| Error::UnrecognizedNetworkCommand(..)
| Error::UnexpectedHexDigit(..) => None,
} }
} }

View File

@ -80,7 +80,8 @@ impl fmt::Display for Error {
match *self { match *self {
Error::Secp256k1(ref e) => fmt::Display::fmt(e, f), Error::Secp256k1(ref e) => fmt::Display::fmt(e, f),
Error::Serialize(ref e) => fmt::Display::fmt(e, f), Error::Serialize(ref e) => fmt::Display::fmt(e, f),
ref x => f.write_str(error::Error::description(x)) Error::Network(ref e) => fmt::Display::fmt(e, f),
Error::SpvBadProofOfWork | Error::SpvBadTarget => f.write_str(error::Error::description(self)),
} }
} }
} }
@ -90,7 +91,8 @@ impl error::Error for Error {
match *self { match *self {
Error::Secp256k1(ref e) => Some(e), Error::Secp256k1(ref e) => Some(e),
Error::Serialize(ref e) => Some(e), Error::Serialize(ref e) => Some(e),
_ => None Error::Network(ref e) => Some(e),
Error::SpvBadProofOfWork | Error::SpvBadTarget => None
} }
} }