1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Boundary-aware substring replacement for Rust-vocabulary-to-host-vocabulary rewrites.
//!
//! Most terminology rewrites in `doc_cleaning` target self-delimiting syntax (`Vec<String>`,
//! `` `Self::tables` ``) where a plain `str::replace` is already boundary-safe because the
//! surrounding `<`, backtick, or punctuation can't be part of a longer identifier. A handful of
//! targets are bare prose words instead (`vec`), and those are prefixes of unrelated longer
//! words (`vector`) that a plain substring replace would silently corrupt.
/// Returns `true` for characters that make up a "word" for the purposes of
/// [`replace_whole_word`]: letters, digits, and underscore.
/// Replace every occurrence of `from` in `text` with `to`, but only when the match is not
/// glued to a longer word on either side.
///
/// A plain `str::replace("empty vec", "empty list")` corrupts "empty vector" into "empty
/// listtor": the naive replace matches the "empty vec" prefix and leaves the "tor" tail of
/// "vector" dangling after the substitution. This checks the character immediately before
/// and after each match and only substitutes when neither neighbor is a word character (or
/// the match sits at the start/end of the string), so a short target term like "vec" is never
/// rewritten when it is really the head of a longer word such as "vector". ~keep
pub