1use crate::boundary::{contains_standalone_module_token, find_standalone_module_token_ranges};
7
8pub use crate::name::module_variant_pairs;
13
14#[must_use]
17pub fn contains_module_token(line: &str, module_name: &str) -> bool {
18 contains_standalone_module_token(line, module_name)
19}
20
21#[must_use]
25pub fn replace_module_token(line: &str, from: &str, to: &str) -> (String, bool) {
26 if from.is_empty() || line.is_empty() {
27 return (line.to_string(), false);
28 }
29
30 let mut ranges = find_standalone_module_token_ranges(line, from).peekable();
31 if ranges.peek().is_none() {
32 return (line.to_string(), false);
33 }
34
35 let mut out = String::with_capacity(line.len());
36 let mut cursor = 0usize;
37
38 for range in ranges {
39 out.push_str(&line[cursor..range.start]);
40 out.push_str(to);
41 cursor = range.end;
42 }
43
44 out.push_str(&line[cursor..]);
45 (out, true)
46}