How to use Searcher
to find exact portions of a byte match.
#1633
-
I'm using the I've created a small repository to reproduce the issue. Here's the entire code: https://github.com/acheronfail/grep-sink-example/blob/master/src/main.rs. See the What did I expect?That the What happens?The Am I using this incorrectly? Should the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You aren't using it incorrectly and this is indeed expected behavior, although it is perhaps a design flaw. In particular, the
This is why hamfisted APIs like If, however, you're working on a problem in which you always find the precise match offsets up front, then the current architecture drops them on the floor, which would require you to re-run your search for each matching line. If matching lines are rare in your particular situation, then this shouldn't be a problem. If matching lines are frequent, then this could be a significant performance problem. I do think the API is flexible enough where we could potentially fix this by enriching the |
Beta Was this translation helpful? Give feedback.
You aren't using it incorrectly and this is indeed expected behavior, although it is perhaps a design flaw. In particular, the
grep-searcher
andgrep-matcher
architecture generally assume two things:This is why hamfisted APIs like
Matcher::find_candidate_line
exist. Indeed, in the most basic grep output format (no color), you never even need the match boundaries in the first place. All you need is the line that matched.If, however, you're working on a problem in which you always…