use crate::normal::NormalString;
#[repr(transparent)]
#[derive(Clone)]
pub struct FastStr(NormalString);
#[allow(unused)]
impl FastStr {
#[inline]
pub(super) fn do_sub_with<
'a,
R: 'a,
F: FnOnce(&'a str, Box<dyn Fn(&str) -> Self + 'a>) -> R,
>(
&'a self,
f: F,
) -> R {
f(self.0.str, Box::new(|str| Self(self.0.map_ref(str))))
}
#[inline]
pub(super) fn do_sub_into<F: FnOnce(&str) -> &str>(self, f: F) -> Self {
let str = f(self.0.str);
Self(self.0.map_ref_into(str))
}
#[inline]
pub const fn new() -> Self {
Self::from_static("")
}
#[inline]
pub const fn from_static(str: &'static str) -> Self {
Self(NormalString::from_static(str))
}
#[inline]
pub fn from_string(str: String) -> Self {
Self(NormalString::from_string(str))
}
#[inline]
pub fn from_ref(str: &str) -> Self {
Self(NormalString::from_string(str.into()))
}
#[inline]
pub fn into_string(self) -> String {
self.0.into_string()
}
#[inline]
pub fn as_str(&self) -> &str {
self.0.as_str()
}
#[inline]
pub fn is_static(&self) -> bool {
self.0.is_static()
}
#[inline]
pub fn static_str(&self) -> Option<&'static str> {
self.0.static_str()
}
}