Skip to content

Precision for debug formatting works with empty tuple, but not other things (odd inconsistency) #43909

Open
@ids1024

Description

@ids1024

It may be intentional that precision doesn't work with debug formatting (only with display), but this inconsistency is odd.

println!("{:?}", ()); // prints '()'
println!("{:.0?}", ()); // prints ''
println!("{:.1?}", ()); // prints '('

// In all of the below, the precision specifier has no effect at all;
// the full debug text is printed
println!("{:.0?}", 125);
println!("{:.1?}", 125);
println!("{:.0?}", (1, 2, 3));
println!("{:.1?}", (1, 2, 3));
println!("{:.0?}", ((), (), ()));
println!("{:.1?}", ((), (), ()));
println!("{:.0?}", "test");
println!("{:.1?}", "test");

I presume this is unintended (I can't imagine why it would be intentional)? Although any change may technically be breaking. Of course, if it is desired that precision doesn't work with debug, it doesn't really matter since there's no reason to use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions