Skip to main content

Module matching

Module matching 

Source
Expand description

The matcher, as a pure function over &str — no document, no store, no threads.

A host app searching a whole project cannot afford to build a document per row just to ask “does this contain that”: it would parse every scene in the manuscript on every keystroke. It extracts the prose cheaply and matches it here instead.

Exposing it is what keeps there being one definition of a match. An app that rolled its own would disagree with this crate’s in-document find about whole-word rules and case folding, and a writer would meet that as “the editor found it but the search panel didn’t”. The same goes for folding and for case preservation: an app that lowercased its own corpus would miss Straße and half-rename a Turkish manuscript. FoldLocale is how a per-scene language reaches the fold. FoldedText is the prepared form: a haystack folded once and searched many times. A search box re-searches the same corpus on every keystroke, and folding it costs several times what scanning it does — so an app that searches a whole project keeps one of these per scene rather than rebuilding the fold per character typed.

Structs§

FoldSpec
What a fold is allowed to fold away.
FoldedText
A haystack folded once, ready to be searched many times.
Match
One occurrence, in char offsets into the original haystack — never into the folded copy.
MatchOptions
How to match.

Enums§

FoldLocale
The locale tailoring that changes how text folds.

Functions§

find_all
Every occurrence of needle in haystack, in original char offsets.
preserve_case
Dress replacement in the case of the text it is replacing.