Trait stylish_stringlike::text::Replaceable[][src]

pub trait Replaceable<T> {
    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

fn replace(&self, from: &str, replacer: T) -> Self[src]

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);

fn replace_regex(&self, searcher: &Regex, replacer: T) -> Self[src]

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"));

Implementors

impl<'a, T> Replaceable<&'a T> for T where
    T: Default + RawText + Sliceable + Pushable<T> + Expandable
[src]

fn replace(&self, from: &str, replacer: &'a T) -> Self[src]

fn replace_regex(&self, searcher: &Regex, replacer: &'a T) -> Self[src]

impl<'a, T: Clone + PartialEq> Replaceable<&'a str> for Spans<T>[src]

fn replace(&self, from: &str, replacer: &'a str) -> Self[src]

fn replace_regex(&self, searcher: &Regex, replacer: &'a str) -> Self[src]