mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
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
@ -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…
Reference in New Issue
Block a user