use crate::temex_match::TemexMatch;
use std::iter::FusedIterator;
/// An iterator over all non-overlapping matches of a trace.
///
/// The iterator yields a `TemexMatch` value. The iterator stops when no
/// more matches can be found.
pub struct TemexMatches<'r, 't> {
pub re_matches: regex::bytes::Matches<'r, 't>,
pub(crate) width: usize,
}
impl Iterator for TemexMatches<'_, '_> {
type Item = TemexMatch;
fn next(&mut self) -> Option<TemexMatch> {
let re_match = self.re_matches.next()?;
let start = re_match.start() / self.width;
let end = re_match.end() / self.width;
Some(TemexMatch { start, end })
}
}
impl FusedIterator for TemexMatches<'_, '_> {}