Skip to content

Commit d0ab70f

Browse files
committed
doc: clarify order of match iterator
Fixes #445
1 parent d5e5da6 commit d0ab70f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/re_set.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ impl SetMatches {
249249
}
250250

251251
/// Returns an iterator over indexes in the regex that matched.
252+
///
253+
/// This will always produces matches in ascending order of index, where
254+
/// the index corresponds to the index of the regex that matched with
255+
/// respect to its position when initially building the set.
252256
pub fn iter(&self) -> SetMatchesIter {
253257
SetMatchesIter((&*self.matches).into_iter().enumerate())
254258
}
@@ -273,6 +277,10 @@ impl<'a> IntoIterator for &'a SetMatches {
273277
}
274278

275279
/// An owned iterator over the set of matches from a regex set.
280+
///
281+
/// This will always produces matches in ascending order of index, where the
282+
/// index corresponds to the index of the regex that matched with respect to
283+
/// its position when initially building the set.
276284
pub struct SetMatchesIntoIter(iter::Enumerate<vec::IntoIter<bool>>);
277285

278286
impl Iterator for SetMatchesIntoIter {
@@ -304,6 +312,10 @@ impl DoubleEndedIterator for SetMatchesIntoIter {
304312
/// A borrowed iterator over the set of matches from a regex set.
305313
///
306314
/// The lifetime `'a` refers to the lifetime of a `SetMatches` value.
315+
///
316+
/// This will always produces matches in ascending order of index, where the
317+
/// index corresponds to the index of the regex that matched with respect to
318+
/// its position when initially building the set.
307319
#[derive(Clone)]
308320
pub struct SetMatchesIter<'a>(iter::Enumerate<slice::Iter<'a, bool>>);
309321

0 commit comments

Comments
 (0)