mozilla/rust — pull request #9442 by Kimundi (2013-09-23 21:57:19+00:00)
Title: RFC: Added an FindIterator to str

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 have of the string library:
- In https://github.com/mozilla/rust/pull/9392, I'm trying to normalize the names for operations that operate starting from the back to `_rev`, which has met some resistance. This PR would allow removing at least `find()` and `rfind()` completely and replace them with a Iterator.
- If we drop the reverse iterator constructors (DoubleEndedIterators already offer an method for inverting them), we'd also remove a lot of repetition - see https://github.com/mozilla/rust/issues/9391.
- The resulting `"foo".find_iter('o').nth(0)` and `"foo".find_iter('f').invert().nth(0)` would become quite long though, which touches on https://github.com/mozilla/rust/issues/9440.