Skip to content

Commit 698e652

Browse files
committed
f hex_utils
1 parent d384ef9 commit 698e652

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hex_utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use bitcoin::secp256k1::PublicKey;
2+
use std::fmt::Write;
23

34
pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
45
let mut out = Vec::with_capacity(hex.len() / 2);
@@ -23,9 +24,9 @@ pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
2324

2425
#[inline]
2526
pub fn to_string(value: &[u8]) -> String {
26-
let mut res = String::with_capacity(64);
27+
let mut res = String::with_capacity(value.len());
2728
for v in value {
28-
res += &format!("{:02x}", v);
29+
write!(&mut res, "{:02x}", v).expect("Unable to write");
2930
}
3031
res
3132
}

0 commit comments

Comments
 (0)