Trait ReplaceWord

Source
pub trait ReplaceWord
where Self: PatternReplace,
{ // Required methods fn replace_word_bounds( &self, word: &str, replacement: &str, bounds: WordBounds, case_insensitive: bool, ) -> Self where Self: Sized; fn replace_word( &self, word: &str, replacement: &str, case_insensitive: bool, ) -> Self where Self: Sized; fn replace_words( &self, pairs: &[(&str, &str)], case_insensitive: bool, ) -> Self where Self: Sized; fn replace_word_sets(&self, pairs: &[(&str, &str, bool)]) -> Self where Self: Sized; // Provided methods fn replace_word_ci(&self, word: &str, replacement: &str) -> Self where Self: Sized { ... } fn replace_word_cs(&self, word: &str, replacement: &str) -> Self where Self: Sized { ... } fn replace_words_ci(&self, pairs: &[(&str, &str)]) -> Self where Self: Sized { ... } fn replace_words_cs(&self, pairs: &[(&str, &str)]) -> Self where Self: Sized { ... } }
Expand description

Methods for whole or partial word replacements

Required Methods§

Source

fn replace_word_bounds( &self, word: &str, replacement: &str, bounds: WordBounds, case_insensitive: bool, ) -> Self
where Self: Sized,

Replace words with boundary and case_insensitive options

Source

fn replace_word( &self, word: &str, replacement: &str, case_insensitive: bool, ) -> Self
where Self: Sized,

Replace whole words with case_insensitive options

Source

fn replace_words(&self, pairs: &[(&str, &str)], case_insensitive: bool) -> Self
where Self: Sized,

Replace one or pairs of whole words with a boolean case_insensitive flag

Source

fn replace_word_sets(&self, pairs: &[(&str, &str, bool)]) -> Self
where Self: Sized,

Replace one or sets of whole words with case_insensitive flags as the last tuple element

Provided Methods§

Source

fn replace_word_ci(&self, word: &str, replacement: &str) -> Self
where Self: Sized,

Replace whole words with in case-insensitive mode

Source

fn replace_word_cs(&self, word: &str, replacement: &str) -> Self
where Self: Sized,

Replace whole words with in case-sensitive mode

Source

fn replace_words_ci(&self, pairs: &[(&str, &str)]) -> Self
where Self: Sized,

Replace one or pairs of whole words in case-insensitive mode

Source

fn replace_words_cs(&self, pairs: &[(&str, &str)]) -> Self
where Self: Sized,

Replace one or pairs of whole words in case-sensitive mode

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ReplaceWord for String

Methods for whole or partial word replacements

Source§

fn replace_word_bounds( &self, word: &str, replacement: &str, bounds: WordBounds, case_insensitive: bool, ) -> String

Replace words with boundary and case_insensitive options

Source§

fn replace_word( &self, word: &str, replacement: &str, case_insensitive: bool, ) -> String

Replace whole words with case_insensitive options

Source§

fn replace_words( &self, pairs: &[(&str, &str)], case_insensitive: bool, ) -> String

Replace one or pairs of whole words with a boolean case_insensitive flag

Source§

fn replace_word_sets(&self, tuples: &[(&str, &str, bool)]) -> String

Replace one or sets of whole words with case_insensitive flags as the last tuple element

Implementors§