Skip to content

Commit 255005c

Browse files
committed
Rename iterator types to match std conventions.
1 parent 3fe0783 commit 255005c

File tree

5 files changed

+76
-76
lines changed

5 files changed

+76
-76
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ pub use re_set::unicode::*;
463463
pub use re_trait::Locations;
464464
pub use re_unicode::{
465465
Regex, Match, Captures,
466-
CaptureNamesIter, CapturesIter, FindIter,
467-
Replacer, NoExpand, SplitsIter, SplitsNIter,
466+
CaptureNames, Matches, CaptureMatches,
467+
Replacer, NoExpand, Split, SplitN,
468468
quote,
469469
};
470470

src/pattern.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::str::pattern::{Pattern, Searcher, SearchStep};
22

3-
use re_unicode::{Regex, FindIter};
3+
use re_unicode::{Regex, Matches};
44

55
pub struct RegexSearcher<'r, 't> {
66
haystack: &'t str,
7-
it: FindIter<'r, 't>,
7+
it: Matches<'r, 't>,
88
last_step_end: usize,
99
next_match: Option<(usize, usize)>,
1010
}

src/re_bytes.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ impl Regex {
184184
/// }
185185
/// # }
186186
/// ```
187-
pub fn find_iter<'r, 't>(&'r self, text: &'t [u8]) -> FindIter<'r, 't> {
188-
FindIter(self.0.searcher().find_iter(text))
187+
pub fn find_iter<'r, 't>(&'r self, text: &'t [u8]) -> Matches<'r, 't> {
188+
Matches(self.0.searcher().find_iter(text))
189189
}
190190

191191
/// Returns the capture groups corresponding to the leftmost-first
@@ -289,8 +289,8 @@ impl Regex {
289289
pub fn captures_iter<'r, 't>(
290290
&'r self,
291291
text: &'t [u8],
292-
) -> CapturesIter<'r, 't> {
293-
CapturesIter(self.0.searcher().captures_iter(text))
292+
) -> CaptureMatches<'r, 't> {
293+
CaptureMatches(self.0.searcher().captures_iter(text))
294294
}
295295

296296
/// Returns an iterator of substrings of `text` delimited by a match of the
@@ -313,8 +313,8 @@ impl Regex {
313313
/// ]);
314314
/// # }
315315
/// ```
316-
pub fn split<'r, 't>(&'r self, text: &'t [u8]) -> SplitsIter<'r, 't> {
317-
SplitsIter {
316+
pub fn split<'r, 't>(&'r self, text: &'t [u8]) -> Split<'r, 't> {
317+
Split {
318318
finder: self.find_iter(text),
319319
last: 0,
320320
}
@@ -344,8 +344,8 @@ impl Regex {
344344
&'r self,
345345
text: &'t [u8],
346346
limit: usize,
347-
) -> SplitsNIter<'r, 't> {
348-
SplitsNIter {
347+
) -> SplitN<'r, 't> {
348+
SplitN {
349349
splits: self.split(text),
350350
n: limit,
351351
}
@@ -644,9 +644,9 @@ impl Regex {
644644
///
645645
/// `'r` is the lifetime of the compiled regular expression and `'t` is the
646646
/// lifetime of the matched byte string.
647-
pub struct FindIter<'r, 't>(re_trait::FindIter<'t, ExecNoSync<'r>>);
647+
pub struct Matches<'r, 't>(re_trait::Matches<'t, ExecNoSync<'r>>);
648648

649-
impl<'r, 't> Iterator for FindIter<'r, 't> {
649+
impl<'r, 't> Iterator for Matches<'r, 't> {
650650
type Item = Match<'t>;
651651

652652
fn next(&mut self) -> Option<Match<'t>> {
@@ -662,9 +662,9 @@ impl<'r, 't> Iterator for FindIter<'r, 't> {
662662
///
663663
/// `'r` is the lifetime of the compiled regular expression and `'t` is the
664664
/// lifetime of the matched byte string.
665-
pub struct CapturesIter<'r, 't>(re_trait::CapturesIter<'t, ExecNoSync<'r>>);
665+
pub struct CaptureMatches<'r, 't>(re_trait::CaptureMatches<'t, ExecNoSync<'r>>);
666666

667-
impl<'r, 't> Iterator for CapturesIter<'r, 't> {
667+
impl<'r, 't> Iterator for CaptureMatches<'r, 't> {
668668
type Item = Captures<'t>;
669669

670670
fn next(&mut self) -> Option<Captures<'t>> {
@@ -680,12 +680,12 @@ impl<'r, 't> Iterator for CapturesIter<'r, 't> {
680680
///
681681
/// `'r` is the lifetime of the compiled regular expression and `'t` is the
682682
/// lifetime of the byte string being split.
683-
pub struct SplitsIter<'r, 't> {
684-
finder: FindIter<'r, 't>,
683+
pub struct Split<'r, 't> {
684+
finder: Matches<'r, 't>,
685685
last: usize,
686686
}
687687

688-
impl<'r, 't> Iterator for SplitsIter<'r, 't> {
688+
impl<'r, 't> Iterator for Split<'r, 't> {
689689
type Item = &'t [u8];
690690

691691
fn next(&mut self) -> Option<&'t [u8]> {
@@ -715,12 +715,12 @@ impl<'r, 't> Iterator for SplitsIter<'r, 't> {
715715
///
716716
/// `'r` is the lifetime of the compiled regular expression and `'t` is the
717717
/// lifetime of the byte string being split.
718-
pub struct SplitsNIter<'r, 't> {
719-
splits: SplitsIter<'r, 't>,
718+
pub struct SplitN<'r, 't> {
719+
splits: Split<'r, 't>,
720720
n: usize,
721721
}
722722

723-
impl<'r, 't> Iterator for SplitsNIter<'r, 't> {
723+
impl<'r, 't> Iterator for SplitN<'r, 't> {
724724
type Item = &'t [u8];
725725

726726
fn next(&mut self) -> Option<&'t [u8]> {

src/re_trait.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ pub trait RegularExpression: Sized {
151151
fn find_iter<'t>(
152152
self,
153153
text: &'t Self::Text,
154-
) -> FindIter<'t, Self> {
155-
FindIter {
154+
) -> Matches<'t, Self> {
155+
Matches {
156156
re: self,
157157
text: text,
158158
last_end: 0,
@@ -165,20 +165,20 @@ pub trait RegularExpression: Sized {
165165
fn captures_iter<'t>(
166166
self,
167167
text: &'t Self::Text,
168-
) -> CapturesIter<'t, Self> {
169-
CapturesIter(self.find_iter(text))
168+
) -> CaptureMatches<'t, Self> {
169+
CaptureMatches(self.find_iter(text))
170170
}
171171
}
172172

173173
/// An iterator over all non-overlapping successive leftmost-first matches.
174-
pub struct FindIter<'t, R> where R: RegularExpression, R::Text: 't {
174+
pub struct Matches<'t, R> where R: RegularExpression, R::Text: 't {
175175
re: R,
176176
text: &'t R::Text,
177177
last_end: usize,
178178
last_match: Option<usize>,
179179
}
180180

181-
impl<'t, R> FindIter<'t, R> where R: RegularExpression, R::Text: 't {
181+
impl<'t, R> Matches<'t, R> where R: RegularExpression, R::Text: 't {
182182
/// Return the text being searched.
183183
pub fn text(&self) -> &'t R::Text {
184184
self.text
@@ -190,7 +190,7 @@ impl<'t, R> FindIter<'t, R> where R: RegularExpression, R::Text: 't {
190190
}
191191
}
192192

193-
impl<'t, R> Iterator for FindIter<'t, R>
193+
impl<'t, R> Iterator for Matches<'t, R>
194194
where R: RegularExpression, R::Text: 't + AsRef<[u8]> {
195195
type Item = (usize, usize);
196196

@@ -222,10 +222,10 @@ impl<'t, R> Iterator for FindIter<'t, R>
222222

223223
/// An iterator over all non-overlapping successive leftmost-first matches with
224224
/// captures.
225-
pub struct CapturesIter<'t, R>(FindIter<'t, R>)
225+
pub struct CaptureMatches<'t, R>(Matches<'t, R>)
226226
where R: RegularExpression, R::Text: 't;
227227

228-
impl<'t, R> CapturesIter<'t, R> where R: RegularExpression, R::Text: 't {
228+
impl<'t, R> CaptureMatches<'t, R> where R: RegularExpression, R::Text: 't {
229229
/// Return the text being searched.
230230
pub fn text(&self) -> &'t R::Text {
231231
self.0.text()
@@ -237,7 +237,7 @@ impl<'t, R> CapturesIter<'t, R> where R: RegularExpression, R::Text: 't {
237237
}
238238
}
239239

240-
impl<'t, R> Iterator for CapturesIter<'t, R>
240+
impl<'t, R> Iterator for CaptureMatches<'t, R>
241241
where R: RegularExpression, R::Text: 't + AsRef<[u8]> {
242242
type Item = Locations;
243243

0 commit comments

Comments
 (0)