diff --git a/src/key.rs b/src/key.rs index 4f715d8..8d883aa 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1277,6 +1277,24 @@ impl Parity { } } +/// `Even` for `0`, `Odd` for `1`, error for anything else +impl TryFrom for Parity { + type Error = InvalidParityValue; + + fn try_from(parity: i32) -> Result { + Self::from_i32(parity) + } +} + +/// `Even` for `0`, `Odd` for `1`, error for anything else +impl TryFrom for Parity { + type Error = InvalidParityValue; + + fn try_from(parity: u8) -> Result { + Self::from_u8(parity) + } +} + /// The conversion returns `0` for even parity and `1` for odd. impl From for i32 { fn from(parity: Parity) -> i32 { diff --git a/src/lib.rs b/src/lib.rs index 327d4af..501baff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -372,8 +372,7 @@ impl fmt::Display for Error { #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for Error { - #[allow(deprecated)] - fn cause(&self) -> Option<&dyn std::error::Error> { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Error::IncorrectSignature => None, Error::InvalidMessage => None,