[][src]Function display_utils::replace_n

pub fn replace_n<'a>(
    source: &'a str,
    from: &'a str,
    to: &'a str,
    n: usize
) -> impl Display + 'a

Replace the first n instances of the from string with the to string.

Note: this function, contrary to its std equivalent str::replacen, does not support the Pattern API because that API is not yet stabilized.

assert_eq!(replace_n("old old old", "old", "new", 2).to_string(), "new new old");