Skip to content

Commit

Permalink
fix hexa and binary print for bytes in sc_print!
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi committed Jul 11, 2024
1 parent 2ddd48b commit 2706b9d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions framework/base/src/formatter/formatter_impl_bytes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use super::{FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex};
use super::{
hex_util::{byte_to_binary_digits, encode_bytes_as_hex},
FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex,
};

impl SCDisplay for &[u8] {
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
Expand All @@ -8,12 +11,14 @@ impl SCDisplay for &[u8] {

impl SCLowerHex for &[u8] {
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
f.append_bytes(self);
f.append_bytes(encode_bytes_as_hex(self).as_bytes());
}
}

impl SCBinary for &[u8] {
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) {
f.append_bytes(self);
for b in self.iter() {
f.append_bytes(&byte_to_binary_digits(*b));
}
}
}

0 comments on commit 2706b9d

Please sign in to comment.