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

Allow any type of argument for one-argument print! invocations #13504

Closed
Manishearth opened this issue Apr 14, 2014 · 1 comment
Closed

Allow any type of argument for one-argument print! invocations #13504

Manishearth opened this issue Apr 14, 2014 · 1 comment

Comments

@Manishearth
Copy link
Member

Currently, if one wants to print a number (or any other non-string value), one has to use println!("{}", 1234), which is a tad unwieldy. println!(1234) throws an error (one-argument invocations only work with strings). It's also annoying to write during debugging.

Why not overload the macros so that println!(expr) is an alias for println!("{}", expr)? This won't break any current behavior, but it will turn an error into something useful.

I have a possible fix on this branch, though eddyb suggested I try to make the changes in format_args! itself. (I'm not so familiar with that code, so I'd prefer to get feedback here before working on that.)

@lifthrasiir
Copy link
Contributor

Previously:

It seems to be a popular feature request with some active criticism indeed.

flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 18, 2024
…=Alexendoo

Check for needless raw strings in `format_args!()` template as well

changelog: [`needless_raw_strings`, `needless_raw_string_hashes`]: check `format_args!()` template as well

Fix rust-lang#13503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants