use std::borrow::Cow;
pub trait StaticString {
fn static_string(self) -> Cow<'static, str>;
}
impl StaticString for &'static str {
fn static_string(self) -> Cow<'static, str> {
Cow::from(self)
}
}
impl StaticString for String {
fn static_string(self) -> Cow<'static, str> {
Cow::from(self)
}
}
impl StaticString for &Cow<'static, str> {
fn static_string(self) -> Cow<'static, str> {
match self {
Cow::Borrowed(string) => Cow::Borrowed(*string),
Cow::Owned(string) => Cow::Owned(string.to_owned()),
}
}
}