use std::borrow::Cow;
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct Markup(pub Cow<'static, str>);
impl Markup {
pub fn empty() -> Self {
Markup(Cow::Borrowed(""))
}
pub fn from_static(s: &'static str) -> Self {
Markup(Cow::Borrowed(s))
}
}
impl fmt::Display for Markup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl From<String> for Markup {
fn from(s: String) -> Self {
Markup(Cow::Owned(s))
}
}
impl From<&'static str> for Markup {
fn from(s: &'static str) -> Self {
Markup(Cow::Borrowed(s))
}
}