ergex icon indicating copy to clipboard operation
ergex copied to clipboard

Ergex's regex API should match the Aho-Corasick API

Open deadpixi opened this issue 2 years ago • 2 comments

The push-oriented implementation of Aho-Corasick returns an iterator over the matches it finds. The public regex API instead reports matches via callbacks. I'd like to see the public API also return an iterator.

Something like:


for match in scratch.push(bytes) {
    // do things
}

A big question is how to handle scratch.finish, which consumes the scratch but also might return matches.

deadpixi avatar Jan 11 '22 04:01 deadpixi

that could be handled using Iterator::collect. the only difference being that it would be possible to get a collection with 0 elements if there are no stored matches in the instance. I admit I haven't seen much of how this library works, but I'm throwing this idea out there.

raghav-deepsource avatar Jan 11 '22 10:01 raghav-deepsource

you could implement drop on the iterator in such a way that it also "finishes" the associated scratch struct...

raghav-deepsource avatar Jan 11 '22 14:01 raghav-deepsource