Description
dynfmt::PythonFormat does not appear to apply zero-padding when formatting integers. For example, formatting an integer with %04d produces 42 instead of 0042.
Reproduction
use dynfmt::{Format, PythonFormat};
fn main() {
let result = PythonFormat
.format("%04d", &[42])
.unwrap();
assert_eq!(result, "0042");
}
- expected behavior:
0042
- actual behavior:
42
Notes
The parser appears to recognize both the field width and the 0 flag, but these formatting options do not seem to be applied when the value is eventually formatted.
Since %04d is valid Python-style % formatting as well as standard printf-style formatting, I would expect PythonFormat to honor the requested width and zero-padding.
It looks like other formatting options stored in the parsed argument specification, such as width/alignment/precision, may potentially be affected by the same issue.
AI Disclaimer
I found this issue myself when using dynfmt on a project. However, I did let ChatGPT write the content of this issue to save time.
Description
dynfmt::PythonFormatdoes not appear to apply zero-padding when formatting integers. For example, formatting an integer with%04dproduces42instead of0042.Reproduction
004242Notes
The parser appears to recognize both the field width and the
0flag, but these formatting options do not seem to be applied when the value is eventually formatted.Since
%04dis valid Python-style%formatting as well as standardprintf-style formatting, I would expectPythonFormatto honor the requested width and zero-padding.It looks like other formatting options stored in the parsed argument specification, such as width/alignment/precision, may potentially be affected by the same issue.
AI Disclaimer
I found this issue myself when using
dynfmton a project. However, I did let ChatGPT write the content of this issue to save time.