Merge rust-bitcoin/rust-secp256k1#409: After MSRV bump: Implemented `TryFrom<{u8, i32}>` for `Parity`
df081bede0
Changed impl `Error::cause()` to `Error::source()` (Martin Habovstiak)cabb8f9e6f
Implemented `TryFrom<{u8, i32}>` for `Parity` (Martin Habovstiak) Pull request description: ACKs for top commit: tcharding: ACKdf081bede0
apoelstra: ACKdf081bede0
Tree-SHA512: 5587a9684a4bfc1f659548a3787ff3602c56b2d6db72e89783529b85b670b681bce7e99683c751a03697c8faa1c2aa2f314c2c9b28e16e4c53fd07b01e949af2
This commit is contained in:
commit
73ad30dda1
18
src/key.rs
18
src/key.rs
|
@ -1277,6 +1277,24 @@ impl Parity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Even` for `0`, `Odd` for `1`, error for anything else
|
||||||
|
impl TryFrom<i32> for Parity {
|
||||||
|
type Error = InvalidParityValue;
|
||||||
|
|
||||||
|
fn try_from(parity: i32) -> Result<Self, Self::Error> {
|
||||||
|
Self::from_i32(parity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `Even` for `0`, `Odd` for `1`, error for anything else
|
||||||
|
impl TryFrom<u8> for Parity {
|
||||||
|
type Error = InvalidParityValue;
|
||||||
|
|
||||||
|
fn try_from(parity: u8) -> Result<Self, Self::Error> {
|
||||||
|
Self::from_u8(parity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The conversion returns `0` for even parity and `1` for odd.
|
/// The conversion returns `0` for even parity and `1` for odd.
|
||||||
impl From<Parity> for i32 {
|
impl From<Parity> for i32 {
|
||||||
fn from(parity: Parity) -> i32 {
|
fn from(parity: Parity) -> i32 {
|
||||||
|
|
|
@ -372,8 +372,7 @@ impl fmt::Display for Error {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||||
impl std::error::Error for Error {
|
impl std::error::Error for Error {
|
||||||
#[allow(deprecated)]
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
|
||||||
match self {
|
match self {
|
||||||
Error::IncorrectSignature => None,
|
Error::IncorrectSignature => None,
|
||||||
Error::InvalidMessage => None,
|
Error::InvalidMessage => None,
|
||||||
|
|
Loading…
Reference in New Issue