Skip to content

format!() ignores width when displaying enums #67162

@dimo414

Description

@dimo414

Similar to the issue reported in #55584 (and #55749), the width parameter is ignored when displaying enums, e.g. this fails:

assert_eq!(&format!("{:10}", Enum::FOO), "foo       ");

Playground Example

Notice this is with Display, not Debug. There's some question in the linked issues what the desired behavior for Debug is, but I think it's a bug that Display formatting would not respect width (and precision).

I'd be willing to take a crack at fixing this if I could get some code pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions