Skip to content

Allow trait-less impls on primitive types when in the corresponding libcore module for each type #6065

Closed
@bstrie

Description

@bstrie

I filed #6045 before I realized that you have to make useless traits to implement methods on primitives. However, we already use lang items to identify core::char as the "canonical" char module, yes? Is it possible then to allow impls directly upon char from within core::char, since we know that it won't have anonymous impls anywhere else? This is what I'd like to be able to do:

impl char {
    fn anything() { ... }
}

without having to make a useless trait first:

trait UselessCharTrait {
    fn anything();
}

impl UselessCharTrait for char {
    fn anything() { ... }
}

This is somewhat more pertinent now that #3048 is WONTFIX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions