Skip to content

library stabilization: allow inherent methods on primitive types #16862

Closed
@aturon

Description

@aturon

Currently, the only way we can provide methods for primitive types like slices it through public extension traits (like Str). This approach has a few downsides:

  • Most important, people are tempted to use these traits for generic programming (taking Str-bounded types, and/or implementing Str on their own types), which is very much not the intention.
  • It clutters the exports of several modules in core and std.
  • It's harder for newcomers to understand what's going on, since it's not clear whether the type or the trait is important.

If we could allow inherent impl blocks for primitive types, we could avoid stabilizing these extension traits.

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