Function display_utils::replace_n[][src]

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

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