Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Added an FindIterator to str #9442

Closed
wants to merge 3 commits into from
Closed

Conversation

Kimundi
Copy link
Member

@Kimundi Kimundi commented Sep 23, 2013

This implements an FindIterator with .find_iter() and .find_rev_iter() on string slices that works like .find() and .rfind(), but returns all matches instead of just the first one.

This touches upon a few other design questions I'm having of the string library:


Also as part of this PR I'm moving str::CharEq to char::CharEq, introduce a new trait ToChar, and implement them both for ascii::Ascii.

I'm doing the movement of CharEq because it seems to me that even though it's being intended to be used by string functions, the actual trait encapsulates something relevant for chars in general. And str.rs needs any chance it can get to become shorter. ;)

The ToChar trait is necessary for the implementation of FindIterator to not include two almost identical copies of the same function in both next() and next_back()

@pnkfelix
Copy link
Member

pnkfelix commented Oct 1, 2013

My gut tells me that we might want to generalize this API to find substrings in a string, rather than individual characters.

(I'd suggest regexps, but it doesn't seem right to shove them into str.rs.)

@alexcrichton
Copy link
Member

Closing due to lack of activity, but feel free to reopen with an updated version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants