Skip to content

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

Closed
@Manishearth

Description

@Manishearth

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions