Skip to content
New issue

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

Result from format_args! cannot be center-aligned within another format string #46569

Open
ColinFinck opened this issue Dec 7, 2017 · 3 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ColinFinck
Copy link
Contributor

I can do println!("{:=^80}", " TEST ") to pretty-print a center-aligned header within equality signs.
However, the alignment is ignored when I do println!("{:=^80}", format_args!(" TEST ")).
I need the latter syntax to further write code like
println!("{:=^80}", format_args!(" TEST {:#016X} ", some_integer)).

I understand that a format_args! result is harder to center-align due to cases where the final width could be unknown. Nevertheless, it should be possible for the compiler to determine the string width in my example cases to let it be center-aligned.

@estebank
Copy link
Contributor

estebank commented Dec 7, 2017

Can't you in this case use println!("{:=^80}", format!(" TEST {:#016X} ", some_integer));?

@ColinFinck
Copy link
Contributor Author

No, my code must run in a no_std environment without heap allocations.

@pietroalbini pietroalbini added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jan 23, 2018
@steveklabnik
Copy link
Member

Triage: not aware of any changes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants