Skip to content

Commit fd9b833

Browse files
committed
Getting rid of SecretKey display methods
1 parent 68896be commit fd9b833

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/key.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@ pub struct SecretKey(pub(crate) [u8; constants::SECRET_KEY_SIZE]);
3232
impl_safe_array_newtype!(SecretKey, u8, constants::SECRET_KEY_SIZE);
3333
impl_safe_debug!(SecretKey);
3434

35-
impl fmt::LowerHex for SecretKey {
36-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37-
for ch in &self.0[..] {
38-
write!(f, "{:02x}", *ch)?;
39-
}
40-
Ok(())
41-
}
42-
}
43-
44-
impl fmt::Display for SecretKey {
45-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
46-
fmt::LowerHex::fmt(self, f)
47-
}
48-
}
49-
5035
impl str::FromStr for SecretKey {
5136
type Err = Error;
5237
fn from_str(s: &str) -> Result<SecretKey, Error> {
@@ -219,7 +204,8 @@ impl SecretKey {
219204
impl ::serde::Serialize for SecretKey {
220205
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
221206
if s.is_human_readable() {
222-
s.collect_str(self)
207+
#[allow(deprecated)]
208+
s.serialize_str(&self.format_secret_key())
223209
} else {
224210
s.serialize_bytes(&self.0[..])
225211
}
@@ -706,10 +692,11 @@ mod test {
706692
#[cfg(fuzzing)]
707693
let pk = PublicKey::from_slice(&[0x02, 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87, 0xfe, 0x91, 0xdd, 0xd1, 0x66]).expect("pk");
708694

695+
#[allow(deprecated)] {
709696
assert_eq!(
710-
sk.to_string(),
697+
sk.format_secret_key(),
711698
"01010101010101010001020304050607ffff0000ffff00006363636363636363"
712-
);
699+
) };
713700
assert_eq!(
714701
SecretKey::from_str("01010101010101010001020304050607ffff0000ffff00006363636363636363").unwrap(),
715702
sk

0 commit comments

Comments
 (0)