rust/library/core
许杰友 Jieyou Xu (Joe) 1b9b515674
Rollup merge of #136662 - thaliaarchi:formatter-pad-char-count, r=m-ou-se
Count char width at most once in `Formatter::pad`

When both width and precision flags are specified, then `Formatter::pad` counts the character width twice. Instead, record the character width when truncating it to the precision, so it does not need to be recomputed. Simplify control flow so the cases are more clear.

Related:
- 6c9e708f4b (`fmt::Formatter::pad`: don't call chars().count() more than one time, 2021-09-01): Reduce counting chars from thrice to twice in worst case
- ede39aeb33 (feat: reinterpret `precision` field for strings, 2016-06-29): Change meaning of precision for strings
- b820748ff5 (Implement formatting arguments for strings and integers, 2013-08-10): Implement `Formatter::pad`
2025-03-05 21:46:33 +08:00
..
src Rollup merge of #136662 - thaliaarchi:formatter-pad-char-count, r=m-ou-se 2025-03-05 21:46:33 +08:00
Cargo.toml Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrum 2025-02-23 11:12:56 +00:00