Skip to content

Commit 1ef788b

Browse files
authored
Merge pull request #1 from dougli1sqrd/issue-53-no_allocate_hex_encode
first attempt at no alloc hex encode of VertexId for Debug impl
2 parents eb6419c + fddc260 commit 1ef788b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/vertex_id.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ pub struct VertexId([u8; 16]); // 128bit
66

77
impl core::fmt::Debug for VertexId {
88
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
9-
write!(f, "VertexId({})", hex::encode(self.0))
9+
let mut buff: [u8; 32] = [0 as u8; 32];
10+
let _ = hex::encode_to_slice(self.0, &mut buff);
11+
let s = core::str::from_utf8(&buff).unwrap();
12+
write!(f, "VertexId({})", s)
1013
}
1114
}
1215

0 commit comments

Comments
 (0)