Skip to content

Commit bc09c1d

Browse files
committed
Made str::MatchIndices a private implementantion detail
1 parent 54f0bea commit bc09c1d

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/libcore/str/mod.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -931,29 +931,43 @@ impl Searcher {
931931
}
932932
}
933933

934-
/// An iterator over the start and end indices of the matches of a
935-
/// substring within a larger string
936934
#[derive(Clone)]
937935
#[unstable(feature = "core", reason = "type may be removed")]
938-
pub struct MatchIndices<'a> {
936+
struct OldMatchIndices<'a> {
939937
// constants
940938
haystack: &'a str,
941939
needle: &'a str,
942940
searcher: Searcher
943941
}
944942

943+
/// An iterator over the start and end indices of the matches of a
944+
/// substring within a larger string
945+
#[derive(Clone)]
946+
#[unstable(feature = "core", reason = "type may be removed")]
947+
pub struct MatchIndices<'a>(OldMatchIndices<'a>);
948+
949+
#[stable]
950+
impl<'a> Iterator for MatchIndices<'a> {
951+
type Item = (uint, uint);
952+
953+
#[inline]
954+
fn next(&mut self) -> Option<(uint, uint)> {
955+
self.0.next()
956+
}
957+
}
958+
945959
/// An iterator over the substrings of a string separated by a given
946960
/// search string
947961
#[derive(Clone)]
948962
#[unstable(feature = "core", reason = "type may be removed")]
949963
pub struct SplitStr<'a> {
950-
it: MatchIndices<'a>,
964+
it: OldMatchIndices<'a>,
951965
last_end: uint,
952966
finished: bool
953967
}
954968

955969
#[stable(feature = "rust1", since = "1.0.0")]
956-
impl<'a> Iterator for MatchIndices<'a> {
970+
impl<'a> Iterator for OldMatchIndices<'a> {
957971
type Item = (uint, uint);
958972

959973
#[inline]
@@ -1465,17 +1479,17 @@ impl StrExt for str {
14651479

14661480
#[inline]
14671481
fn match_indices<'a>(&'a self, sep: &'a str) -> MatchIndices<'a> {
1468-
MatchIndices {
1482+
MatchIndices(OldMatchIndices {
14691483
haystack: self,
14701484
needle: sep,
14711485
searcher: Searcher::new(self.as_bytes(), sep.as_bytes())
1472-
}
1486+
})
14731487
}
14741488

14751489
#[inline]
14761490
fn split_str<'a>(&'a self, sep: &'a str) -> SplitStr<'a> {
14771491
SplitStr {
1478-
it: self.match_indices(sep),
1492+
it: self.match_indices(sep).0,
14791493
last_end: 0,
14801494
finished: false
14811495
}

src/libcore/str/pattern.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ impl<'a, C: CharEq> DoubleEndedMatcher<'a> for CharEqMatcher<'a, C> {}
8484

8585
// Impl for &str
8686

87-
struct StrMatcher<'a>(super::MatchIndices<'a>);
87+
struct StrMatcher<'a>(super::OldMatchIndices<'a>);
8888

8989
impl<'a> Pattern<'a> for &'a str {
9090
type Matcher = StrMatcher<'a>;
9191

9292
#[inline]
9393
fn into_matcher(self, haystack: &'a str) -> StrMatcher<'a> {
94-
let mi = super::MatchIndices {
94+
let mi = super::OldMatchIndices {
9595
haystack: haystack,
9696
needle: self,
9797
searcher: super::Searcher::new(haystack.as_bytes(), self.as_bytes())

0 commit comments

Comments
 (0)