1use std::borrow::Cow;
2use std::fmt;
3
4#[derive(Clone, Debug, PartialEq, Eq, Default)]
10pub struct Markup(pub Cow<'static, str>);
11
12impl Markup {
13 pub fn empty() -> Self {
15 Markup(Cow::Borrowed(""))
16 }
17
18 pub fn from_static(s: &'static str) -> Self {
20 Markup(Cow::Borrowed(s))
21 }
22}
23
24impl fmt::Display for Markup {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 f.write_str(&self.0)
27 }
28}
29
30impl From<String> for Markup {
31 fn from(s: String) -> Self {
32 Markup(Cow::Owned(s))
33 }
34}
35
36impl From<&'static str> for Markup {
37 fn from(s: &'static str) -> Self {
38 Markup(Cow::Borrowed(s))
39 }
40}