pub trait Replaceable<T> {
// Required methods
fn replace(&self, from: &str, replacer: T) -> Self;
fn replace_regex(&self, searcher: &Regex, replacer: T) -> Self;
}Expand description
Replacing text in text-like objects.
This is implemented for String by default.
Required Methods§
Sourcefn replace(&self, from: &str, replacer: T) -> Self
fn replace(&self, from: &str, replacer: T) -> Self
Perform literal string replacement.
§Example
use stylish_stringlike::text::*;
let foo = String::from("foo");
let bar = Replaceable::<&String>::replace(&foo, "foo", &String::from("bar"));
assert_eq!(String::from("bar"), bar);Sourcefn replace_regex(&self, searcher: &Regex, replacer: T) -> Self
fn replace_regex(&self, searcher: &Regex, replacer: T) -> Self
Perform regex string replacement.
§Example
use regex::Regex;
use stylish_stringlike::text::*;
let foooo = String::from("foooo");
let re = Regex::new("fo+").unwrap();
let bar = Replaceable::<&String>::replace_regex(&foooo, &re, &String::from("bar"));
assert_eq!(bar, String::from("bar"));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.