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.