Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hex breaking change #50

Merged
merged 1 commit into from
May 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions crates/primitives/src/bits/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,19 +377,13 @@ impl<const N: usize> core::str::FromStr for FixedBytes<N> {

impl<const N: usize> FixedBytes<N> {
fn fmt_hex(&self, f: &mut fmt::Formatter<'_>, prefix: bool) -> fmt::Result {
if prefix {
f.write_str("0x")?;
}
let mut buf = hex::Buffer::new();
f.write_str(buf.format(&self.0))
let mut buf = hex::Buffer::<N, true>::new();
f.write_str(&buf.format(&self.0)[(!prefix as usize) * 2..])
}

fn fmt_hex_upper(&self, f: &mut fmt::Formatter<'_>, prefix: bool) -> fmt::Result {
if prefix {
f.write_str("0x")?;
}
let mut buf = hex::Buffer::new();
f.write_str(buf.format_upper(&self.0))
let mut buf = hex::Buffer::<N, true>::new();
f.write_str(&buf.format_upper(&self.0)[(!prefix as usize) * 2..])
}
}

Expand Down