mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +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
|
let nchars: usize = self
|
||||||
.utf8_chunks()
|
.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();
|
.sum();
|
||||||
let padding = f.width().unwrap_or(0).saturating_sub(nchars);
|
let padding = f.width().unwrap_or(0).saturating_sub(nchars);
|
||||||
let fill = f.fill();
|
let fill = f.fill();
|
||||||
|
Loading…
Reference in New Issue
Block a user