Skip to main content

Module tools_search

Module tools_search 

Source
Expand description

search_files: find where a pattern appears, without reading files one at a time.

Two targets, one tool, because they answer the same question — “where is this?” — and a model that has to choose between search_files and find_files chooses wrong at least once a session:

  • target: "content" (the default) walks the tree and matches pattern as a regular expression against one line at a time, printing path:line:content.
  • target: "files" matches file names — a glob (*.rs) or, when the pattern has no glob characters in it, a substring.

The walk is rooted at the workspace the way read_file is: one confine call, so a search cannot reach a path a read would be refused. It is also bounded in three places — matches (limit), files visited, and bytes per file — because a pattern that matches everything is the normal case (fn ) and an unbounded answer is a context bill, not a result. Whatever the bound cuts is reported: a search that says “stopped at 50” is usable, one that quietly returns the first 50 is a lie.

Structs§

SearchFiles