pub trait Replaceable: Searchable {
// Required method
fn replace(
&mut self,
pattern: &str,
replace_pattern: &str,
case_sensitive: bool,
matching_mode: &MatchingMode,
search_matches: &Self::SearchMatches,
) -> bool;
}Expand description
Trait for searchable types that also support replacement.
Extends Searchable to allow replacing matched text with new content.
Not all searchable types support replacement (e.g., read-only or binary files).
Required Methods§
Sourcefn replace(
&mut self,
pattern: &str,
replace_pattern: &str,
case_sensitive: bool,
matching_mode: &MatchingMode,
search_matches: &Self::SearchMatches,
) -> bool
fn replace( &mut self, pattern: &str, replace_pattern: &str, case_sensitive: bool, matching_mode: &MatchingMode, search_matches: &Self::SearchMatches, ) -> bool
Replaces matched text with the replacement pattern.
§Arguments
pattern- The original search patternreplace_pattern- The text to replace matches with (literal, no regex)case_sensitive- Whether matching should be case-sensitivematching_mode- How to interpret the search patternsearch_matches- Previously found matches to replace
§Returns
true if any replacements were made, false if no changes occurred.
§Note
Replacements may fail if:
- The search matches are outdated (file was modified since search)
- The replacement text is identical to the matched text