pub fn replace_with_pad_char<'a, C>(
s: &'a mut str,
r: &str,
pad_char: C,
) -> Result<&'a mut str, ReplaceWithPadCharError>Expand description
Replace the str with another of the same length or shorter.
The remaining bytes will be filled with pad, which must be one byte long.
use mut_str::replace_with_pad_char;
let mut owned_s = Box::<str>::from("World!");
replace_with_pad_char(&mut *owned_s, "๐", '!').unwrap();
assert_eq!(&*owned_s, "๐!!");
replace_with_pad_char(&mut *owned_s, "aaaa", 'b').unwrap();
assert_eq!(&*owned_s, "aaaabb");ยงErrors
- If
pad_char, when utf8 encoded, is longer thanSelf,ReplaceWithPadCharError::PadCharTooLongwill be returned. - If
r, when utf8 encoded, is longer thans, when utf8 encoded,ReplaceWithPadCharError::ReplacementLenwill be returned.