diff --git a/crates/nostr/src/key/public_key.rs b/crates/nostr/src/key/public_key.rs index 240f09e18..7cb3e0918 100644 --- a/crates/nostr/src/key/public_key.rs +++ b/crates/nostr/src/key/public_key.rs @@ -92,7 +92,7 @@ impl PublicKey { /// Get public key as `hex` string #[inline] pub fn to_hex(&self) -> String { - hex::encode(&self.to_bytes()) + hex::encode(self.to_bytes()) } /// Get public key as `bytes` diff --git a/crates/nostr/src/util/hex.rs b/crates/nostr/src/util/hex.rs index 0a7ba2298..e9ef7bba9 100644 --- a/crates/nostr/src/util/hex.rs +++ b/crates/nostr/src/util/hex.rs @@ -50,7 +50,11 @@ const fn from_digit(num: u8) -> u8 { /// Hex encode #[inline] -pub fn encode(data: &[u8]) -> String { +pub fn encode(data: T) -> String +where + T: AsRef<[u8]>, +{ + let data: &[u8] = data.as_ref(); let mut hex: String = String::with_capacity(2 * data.len()); for byte in data.iter() { hex.push(from_digit(byte >> 4) as char);