Made str::MatchIndices a private implementantion detail
This commit is contained in:
parent
54f0bead81
commit
bc09c1ddc5
@ -931,29 +931,43 @@ impl Searcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over the start and end indices of the matches of a
|
||||
/// substring within a larger string
|
||||
#[derive(Clone)]
|
||||
#[unstable(feature = "core", reason = "type may be removed")]
|
||||
pub struct MatchIndices<'a> {
|
||||
struct OldMatchIndices<'a> {
|
||||
// constants
|
||||
haystack: &'a str,
|
||||
needle: &'a str,
|
||||
searcher: Searcher
|
||||
}
|
||||
|
||||
/// An iterator over the start and end indices of the matches of a
|
||||
/// substring within a larger string
|
||||
#[derive(Clone)]
|
||||
#[unstable(feature = "core", reason = "type may be removed")]
|
||||
pub struct MatchIndices<'a>(OldMatchIndices<'a>);
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for MatchIndices<'a> {
|
||||
type Item = (uint, uint);
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<(uint, uint)> {
|
||||
self.0.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over the substrings of a string separated by a given
|
||||
/// search string
|
||||
#[derive(Clone)]
|
||||
#[unstable(feature = "core", reason = "type may be removed")]
|
||||
pub struct SplitStr<'a> {
|
||||
it: MatchIndices<'a>,
|
||||
it: OldMatchIndices<'a>,
|
||||
last_end: uint,
|
||||
finished: bool
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> Iterator for MatchIndices<'a> {
|
||||
impl<'a> Iterator for OldMatchIndices<'a> {
|
||||
type Item = (uint, uint);
|
||||
|
||||
#[inline]
|
||||
@ -1465,17 +1479,17 @@ impl StrExt for str {
|
||||
|
||||
#[inline]
|
||||
fn match_indices<'a>(&'a self, sep: &'a str) -> MatchIndices<'a> {
|
||||
MatchIndices {
|
||||
MatchIndices(OldMatchIndices {
|
||||
haystack: self,
|
||||
needle: sep,
|
||||
searcher: Searcher::new(self.as_bytes(), sep.as_bytes())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn split_str<'a>(&'a self, sep: &'a str) -> SplitStr<'a> {
|
||||
SplitStr {
|
||||
it: self.match_indices(sep),
|
||||
it: self.match_indices(sep).0,
|
||||
last_end: 0,
|
||||
finished: false
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ impl<'a, C: CharEq> DoubleEndedMatcher<'a> for CharEqMatcher<'a, C> {}
|
||||
|
||||
// Impl for &str
|
||||
|
||||
struct StrMatcher<'a>(super::MatchIndices<'a>);
|
||||
struct StrMatcher<'a>(super::OldMatchIndices<'a>);
|
||||
|
||||
impl<'a> Pattern<'a> for &'a str {
|
||||
type Matcher = StrMatcher<'a>;
|
||||
|
||||
#[inline]
|
||||
fn into_matcher(self, haystack: &'a str) -> StrMatcher<'a> {
|
||||
let mi = super::MatchIndices {
|
||||
let mi = super::OldMatchIndices {
|
||||
haystack: haystack,
|
||||
needle: self,
|
||||
searcher: super::Searcher::new(haystack.as_bytes(), self.as_bytes())
|
||||
|
Loading…
x
Reference in New Issue
Block a user