use super::*;
impl<'a, U, T: Text<'a>> Add<U> for PrettyTree<'a, T>
where
U: Into<Self>,
{
type Output = Self;
fn add(self, rhs: U) -> Self::Output {
self.append(rhs.into())
}
}
impl<'a, U, T: Text<'a>> AddAssign<U> for PrettyTree<'a, T>
where
U: Into<Self>,
{
fn add_assign(&mut self, rhs: U) {
*self = self.clone().append(rhs.into());
}
}
impl<'a, U, T> From<Option<U>> for PrettyTree<'a, T>
where
Self: From<U>,
{
fn from(x: Option<U>) -> Self {
match x {
Some(x) => x.into(),
None => Self::Nil,
}
}
}
impl<'a, T> From<()> for PrettyTree<'a, T> {
fn from(_: ()) -> Self {
Self::Nil
}
}
impl<'a, T: Text<'a>> From<&'static str> for PrettyTree<'a, T> {
fn from(s: &'static str) -> Self {
Self::Text(T::from_static_str(s))
}
}
impl<'a, T: Text<'a>> From<T> for PrettyTree<'a, T> {
fn from(s: T) -> Self {
Self::Text(s)
}
}