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