use std::borrow::Cow;
#[derive(Debug, Clone)]
pub struct Prepend {
prepend: String,
}
impl Prepend {
#[inline]
pub fn new(prepend: String) -> Self {
Self { prepend }
}
pub fn normalize<'a>(&self, input: &'a str) -> Cow<'a, str> {
if self.prepend.is_empty() {
return Cow::Borrowed(input);
}
let hint = self.prepend.len() + input.len();
let mut result = String::with_capacity(hint);
result.push_str(&self.prepend);
result.push_str(input);
Cow::Owned(result)
}
}