Skip to content

The each_char method on &str doesn't work because multiple applicable methods are in scope #6281

Description

@Thiez

The following program

fn main() {
    do "somestr".each_char |_| { false }
}

Gives this error:

treegrep.rs:2:39: 2:40 error: multiple applicable methods in scope
treegrep.rs:2     do "somestr".each_char |_| { false }
                                                     ^
treegrep.rs:2:39: 2:40 note: candidate #1 is `core::io::__extensions__::each_char`
treegrep.rs:2     do "somestr".each_char |_| { false }
                                                     ^
treegrep.rs:2:39: 2:40 note: candidate #2 is `core::str::__extensions__::each_char`
treegrep.rs:2     do "somestr".each_char |_| { false }
                                                     ^
treegrep.rs:2:39: 2:40 error: failed to find an implementation of trait core::io::Reader for &'static str
treegrep.rs:2     do "somestr".each_char |_| { false }
                                                     ^

It seems this significantly reduces the utility of each_char. Interestingly the last error (failed to find an implementation...) only shows up about half the time.
I'm not entirely sure how &str implements ReaderUtil.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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