pub fn replace_with_pad_space<'a>(
s: &'a mut str,
r: &str,
) -> Result<&'a mut str, ReplacementTooLong>Expand description
Replace the str with another of the same length or shorter.
The remaining bytes will be filled with spaces.
use mut_str::replace_with_pad_space;
let mut owned_s = Box::<str>::from("World!");
replace_with_pad_space(&mut *owned_s, "๐").unwrap();
assert_eq!(&*owned_s, "๐ ");
replace_with_pad_space(&mut *owned_s, "aaaa").unwrap();
assert_eq!(&*owned_s, "aaaa ");ยงErrors
- If
r, when utf8 encoded, is longer thans, when utf8 encoded,ReplacementTooLongwill be returned.