Skip to content

str::trim_left and str::trim_right method names are misleading #39499

@jimblandy

Description

@jimblandy

If you're processing text in a language written from right to left, these methods do the opposite of what they claim. They really refer to the start and end of the slice.

It might be good to have trim_start and trim_end aliases (with _matches variants as well) to help people write clearer code in applications that typically process right-to-left text.

The rest of the API is pretty good about avoiding this mistake; the only other exception I noticed was the std::fmt alignment flags.

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