Rollup merge of #137772 - thaliaarchi:bstr-display, r=joshtriplett
Fix char count in `Display` for `ByteStr` `ByteStr as Display` performs a byte count when a char count is required. r? ```````````@joshtriplett```````````
This commit is contained in:
commit
fe926384c1
1 changed files with 3 additions and 1 deletions
|
@ -151,7 +151,9 @@ impl fmt::Display for ByteStr {
|
|||
};
|
||||
let nchars: usize = self
|
||||
.utf8_chunks()
|
||||
.map(|chunk| chunk.valid().len() + if chunk.invalid().is_empty() { 0 } else { 1 })
|
||||
.map(|chunk| {
|
||||
chunk.valid().chars().count() + if chunk.invalid().is_empty() { 0 } else { 1 }
|
||||
})
|
||||
.sum();
|
||||
let padding = f.width().unwrap_or(0).saturating_sub(nchars);
|
||||
let fill = f.fill();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue