We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
hex_utils
1 parent d384ef9 commit 698e652Copy full SHA for 698e652
src/hex_utils.rs
@@ -1,4 +1,5 @@
1
use bitcoin::secp256k1::PublicKey;
2
+use std::fmt::Write;
3
4
pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
5
let mut out = Vec::with_capacity(hex.len() / 2);
@@ -23,9 +24,9 @@ pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
23
24
25
#[inline]
26
pub fn to_string(value: &[u8]) -> String {
- let mut res = String::with_capacity(64);
27
+ let mut res = String::with_capacity(value.len());
28
for v in value {
- res += &format!("{:02x}", v);
29
+ write!(&mut res, "{:02x}", v).expect("Unable to write");
30
}
31
res
32
0 commit comments