This crate provides an interface for regular expressions, with a focus on line
oriented search. The purpose of this crate is to provide a low level matching
interface that permits any kind of substring or regex implementation to power
the search routines provided by the
The primary thing provided by this crate is the
Matcher trait. The trait
defines an abstract interface for text search. It is robust enough to support
everything from basic substring search all the way to arbitrarily complex
regular expression implementations without sacrificing performance.
A key design decision made in this crate is the use of internal iteration,
or otherwise known as the “push” model of searching. In this paradigm,
implementations of the
Matcher trait will drive search and execute callbacks
provided by the caller when a match is found. This is in contrast to the
usual style of external iteration (the “pull” model) found throughout the
Rust ecosystem. There are two primary reasons why internal iteration was
- Some search implementations may themselves require internal iteration. Converting an internal iterator to an external iterator can be non-trivial and sometimes even practically impossible.
- Rust’s type system isn’t quite expressive enough to write a generic interface using external iteration without giving something else up (namely, ease of use and/or performance).
In other words, internal iteration was chosen because it is the lowest common denominator and because it is probably the least bad way of expressing the interface in today’s Rust. As a result, this trait isn’t specifically intended for everyday use, although, you might find it to be a happy price to pay if you want to write code that is generic over multiple different regex implementations.
- A set of bytes.
- A line terminator.
- The type of a match.
- NoCaptures provides an always-empty implementation of the
- NoError provides an error type for matchers that never produce errors.
- The type of match for a line oriented matcher.
- A trait that describes implementations of capturing groups.
- A matcher defines an interface for regular expression implementations.