feat(elements): into_owned function

This commit is contained in:
PoiScript 2019-08-10 20:17:39 +08:00
parent 9bc260627b
commit f2d0a1dd2d
25 changed files with 475 additions and 131 deletions

View file

@ -18,6 +18,19 @@ pub enum Table<'a> {
TableEl { value: Cow<'a, str> },
}
impl Table<'_> {
pub fn into_owned(self) -> Table<'static> {
match self {
Table::Org { tblfm } => Table::Org {
tblfm: tblfm.map(Into::into).map(Cow::Owned),
},
Table::TableEl { value } => Table::TableEl {
value: value.into_owned().into(),
},
}
}
}
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
#[cfg_attr(feature = "ser", derive(serde::Serialize))]