Function mut_str::replace_with_pad_left

source ·
pub fn replace_with_pad_left<'a>(
    s: &'a mut str,
    r: &str,
    pad: u8
) -> Result<&'a mut str, ReplaceWithPadError>
Expand description

Replace the str with another of the same length or shorter, right aligned. The remaining bytes before the character str will be filled with pad.

use mut_str::replace_with_pad_left;

let mut owned_s = Box::<str>::from("World!");

replace_with_pad_left(&mut *owned_s, "🌍", b'!').unwrap();
assert_eq!(&*owned_s, "!!🌍");

replace_with_pad_left(&mut *owned_s, "aaaa", b'b').unwrap();
assert_eq!(&*owned_s, "bbaaaa");

§Errors