use std::borrow::Cow;
#[allow(clippy::len_without_is_empty)]
pub trait Text<'a>: Sized + Clone + 'a {
fn from_static_str(s: &'static str) -> Self;
fn from_static_spaces(s: &'static str) -> Self {
Self::from_static_str(s)
}
fn as_str(&self) -> Cow<'_, str>;
fn len(&self) -> usize {
str::len(&self.as_str())
}
fn space() -> Self {
Self::from_static_str(" ")
}
fn newline() -> Self {
Self::from_static_str("\n")
}
fn comma_space() -> Self {
Self::from_static_str(", ")
}
}
impl<'a> Text<'a> for Cow<'a, str> {
fn from_static_str(s: &'static str) -> Self {
Cow::Borrowed(s)
}
fn as_str(&self) -> Cow<'a, str> {
self.clone()
}
}