pub struct PatternSplitter { /* private fields */ }Expand description
A compiled multi-pattern splitter for efficient repeated splitting.
Unlike split_at_patterns which rebuilds the Aho-Corasick automaton on each call,
PatternSplitter compiles the automaton once and reuses it. This is ~25x faster
when splitting multiple texts with the same patterns.
§Example
use chunk::{PatternSplitter, IncludeDelim};
// Compile once
let splitter = PatternSplitter::new(&[b". ", b"? ", b"! "]);
// Reuse for multiple texts
let offsets1 = splitter.split(b"Hello. World?", IncludeDelim::Prev, 0);
let offsets2 = splitter.split(b"Another. Text!", IncludeDelim::Prev, 0);Implementations§
Auto Trait Implementations§
impl Freeze for PatternSplitter
impl RefUnwindSafe for PatternSplitter
impl Send for PatternSplitter
impl Sync for PatternSplitter
impl Unpin for PatternSplitter
impl UnwindSafe for PatternSplitter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more