replace

Function replace 

Source
pub fn replace<S, R>(base: &mut String, find: &S, replace: &R)
where S: ToString, R: ToString,
Expand description

§Description

Replaces all occurrences of a substring in a base string with another given term. The base string provided will be modified. All provided arguments are assumed to be valid UTF-8 chars.

§Arguments

  • base - The full base string. The base string will be modified by the function call.
  • find - The substring we are going to replace in the base string.
  • replace - The new string that replaces all occurrences of the find string.

§Examples

use string_simple::modify::replace;

let mut base_string = String::from("This is my base string!");
let find_string = String::from("base");
let replace_string = String::from("modified");

// The base string will be "This is my modified string!"
replace(&mut base_string, &find_string, &replace_string);