Skip to content

Reduce the number of format specifiers #9807

Closed
@orenbenkiki

Description

@orenbenkiki

Given the existence of {} and the Default trait, there's no real value in {:i}, {:u}, {:t}, etc. other than for providing very rudimentary type checking for the parameters passed to format!.

It would be simpler to just use {} everywhere and only use specifiers for things like changing the base of printed integers (that is, only keep specifiers such as {:x} which actually affect the way the printing is done).

If specifiers are only used for changing the base of printed integers, then their implementation can be simplified to just setting a current base member of the format which would be available to the implementation of the formatting in the Default trait, instead of using a trait per each specifier.

This way we'd end up with having to implement just one trait for printing any type, including number-like types, instead of having to implement multiple traits (one per base).

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