pub struct RegexBuf<const N: usize = DEFAULT_NODES, const CCL: usize = DEFAULT_CCL, const MEMO: usize = DEFAULT_MEMO> { /* private fields */ }Expand description
An owned, compiled regex pattern with compile-time-fixed storage.
N— node capacity: max compiled pattern symbols.CCL— character-class buffer size in bytes.MEMO— memo table size in bytes; use(N * DEFAULT_MATCH_TEXT_LEN + 7) / 8.
For the common case use Regex (a type alias for
RegexBuf<32, 64, 256>) so you never spell out the parameters.
Use RegexBuf directly only when you need non-default sizes.
Created via RegexBuf::new; the pattern can be updated in-place via
RegexBuf::recompile. Use find_at and
find_iter to search.
A RegexBuf is always valid — construction fails explicitly via None.
Each find_at call stack-allocates and zeros a [u8; MEMO] memo table
independently, so RegexBuf is Send + Sync without unsafe.
Implementations§
Source§impl<const N: usize, const CCL: usize, const MEMO: usize> RegexBuf<N, CCL, MEMO>
impl<const N: usize, const CCL: usize, const MEMO: usize> RegexBuf<N, CCL, MEMO>
Sourcepub fn find_at<'a>(&self, haystack: &'a CStr, start: usize) -> Option<Match<'a>>
pub fn find_at<'a>(&self, haystack: &'a CStr, start: usize) -> Option<Match<'a>>
Search haystack for the first match of this pattern at or after byte
offset start.
Returns None if no match is found. Each call stack-allocates a
zero-initialised memo table to cache failed (pattern_node, text_offset)
states and eliminate exponential backtracking.