correctly handle 1 byte ranges

This commit is contained in:
Intege-rs
2025-09-13 22:34:02 -04:00
parent 8607716cb8
commit 9d0e3cbc3a

View File

@@ -44,15 +44,10 @@ impl<'s, T: Scannable + ?Sized, R: RangeBounds<usize>> Display for HexDump<'s, T
(start, end) (start, end)
}; };
// if there is nothing to print then just return...
// this also prevents the ilog below from crashing :)
if end == 0 || start > end {
write!(f,"<empty>");
return Ok(())
}
// the number of digits the address column should have // the number of digits the address column should have
let digits = (end.ilog(16) as usize + 1).max(4); let digits = if end == 0 { 4 } else {
(end.ilog(16) as usize + 1).max(4)
};
for (mut addr, chunk) in ChunkIter::new(self.0, start) { for (mut addr, chunk) in ChunkIter::new(self.0, start) {
for chunk in chunk.chunks(16) { for chunk in chunk.chunks(16) {