use crate::boundary::{contains_standalone_module_token, find_standalone_module_token_ranges};
pub use crate::name::module_variant_pairs;
#[must_use]
pub fn contains_module_token(line: &str, module_name: &str) -> bool {
contains_standalone_module_token(line, module_name)
}
#[must_use]
pub fn replace_module_token(line: &str, from: &str, to: &str) -> (String, bool) {
if from.is_empty() || line.is_empty() {
return (line.to_string(), false);
}
let mut ranges = find_standalone_module_token_ranges(line, from).peekable();
if ranges.peek().is_none() {
return (line.to_string(), false);
}
let mut out = String::with_capacity(line.len());
let mut cursor = 0usize;
for range in ranges {
out.push_str(&line[cursor..range.start]);
out.push_str(to);
cursor = range.end;
}
out.push_str(&line[cursor..]);
(out, true)
}