Function std::str::replaceDeprecated
[-]
[+]
[src]
pub fn replace(s: &str, from: &str, to: &str) -> String
Replaces all occurrences of one string with another.
Arguments
- s - The string containing substrings to replace
- from - The string to replace
- to - The replacement string
Return value
The original string with all occurrences of from
replaced with to
.
Examples
fn main() { #![allow(deprecated)] use std::str; let string = "orange"; let new_string = str::replace(string, "or", "str"); assert_eq!(new_string.as_slice(), "strange"); }use std::str; let string = "orange"; let new_string = str::replace(string, "or", "str"); assert_eq!(new_string.as_slice(), "strange");