We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried this code:
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=be8ab0a90dce4f0e53f964e41a4ae89e fn main() { println!("'{:5?}'", 1); println!("'{:w$?}'", 2, w=5); println!("'{:5}'", "3"); println!("'{:w$}'", "4", w=5); println!("'{:5?}'", "5"); println!("'{:w$?}'", "6", w=5); }
I expected to see this happen:
' 1' ' 2' '3 ' '4 ' '"5" ' '"6" '
Instead, this happened:
' 1' ' 2' '3 ' '4 ' '"5"' '"6"'
To summarize, println!() / format!() ignores width while formatting Debug in some cases but not others.
println!()
format!()
rustc --version --verbose:
rustc --version --verbose
rustc 1.54.0 (a178d0322 2021-07-26) binary: rustc commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633 commit-date: 2021-07-26 host: x86_64-apple-darwin release: 1.54.0 LLVM version: 12.0.1
I confirmed the unexpected behavior also happens in beta and nightly:
The text was updated successfully, but these errors were encountered:
Duration
fmt::Debug
width
closing as duplicate of #30164
Sorry, something went wrong.
No branches or pull requests
I tried this code:
I expected to see this happen:
Instead, this happened:
To summarize,
println!()
/format!()
ignores width while formatting Debug in some cases but not others.Meta
rustc --version --verbose
:I confirmed the unexpected behavior also happens in beta and nightly:
See Also
format!()
macro : Macro: std::formatThe text was updated successfully, but these errors were encountered: