Skip to content

Commit 631e595

Browse files
committed
Explicitly set RecoveryId value
At the moment its implicit in the name, make it explicit.
1 parent 319fa08 commit 631e595

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

src/ecdsa/recovery.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use crate::{key, Error, Message, Secp256k1, Signing, Verification};
1616
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
1717
pub enum RecoveryId {
1818
/// Signature recovery ID 0
19-
Zero,
19+
Zero = 0,
2020
/// Signature recovery ID 1
21-
One,
21+
One = 1,
2222
/// Signature recovery ID 2
23-
Two,
23+
Two = 2,
2424
/// Signature recovery ID 3
25-
Three,
25+
Three = 3,
2626
}
2727

2828
impl RecoveryId {
@@ -38,14 +38,7 @@ impl RecoveryId {
3838
}
3939

4040
/// Returns the `RecoveryId` as an integer.
41-
pub const fn to_u8(self) -> u8 {
42-
match self {
43-
RecoveryId::Zero => 0,
44-
RecoveryId::One => 1,
45-
RecoveryId::Two => 2,
46-
RecoveryId::Three => 3,
47-
}
48-
}
41+
pub const fn to_u8(self) -> u8 { self as u8 }
4942
}
5043

5144
impl TryFrom<i32> for RecoveryId {
@@ -64,14 +57,7 @@ impl TryFrom<i32> for RecoveryId {
6457

6558
impl From<RecoveryId> for u8 {
6659
#[inline]
67-
fn from(val: RecoveryId) -> Self {
68-
match val {
69-
RecoveryId::Zero => 0,
70-
RecoveryId::One => 1,
71-
RecoveryId::Two => 2,
72-
RecoveryId::Three => 3,
73-
}
74-
}
60+
fn from(val: RecoveryId) -> Self { val.to_u8() }
7561
}
7662

7763
/// An ECDSA signature with a recovery ID for pubkey recovery.

0 commit comments

Comments
 (0)