Skip to main content

logparse_pretty_print/tree/
into.rs

1use super::*;
2
3impl<'a, U, T: Text<'a>> Add<U> for PrettyTree<'a, T>
4where
5    U: Into<Self>,
6{
7    type Output = Self;
8    fn add(self, rhs: U) -> Self::Output {
9        self.append(rhs.into())
10    }
11}
12
13impl<'a, U, T: Text<'a>> AddAssign<U> for PrettyTree<'a, T>
14where
15    U: Into<Self>,
16{
17    fn add_assign(&mut self, rhs: U) {
18        *self = self.clone().append(rhs.into());
19    }
20}
21
22impl<'a, U, T> From<Option<U>> for PrettyTree<'a, T>
23where
24    Self: From<U>,
25{
26    fn from(x: Option<U>) -> Self {
27        match x {
28            Some(x) => x.into(),
29            None => Self::Nil,
30        }
31    }
32}
33
34impl<'a, T> From<()> for PrettyTree<'a, T> {
35    fn from(_: ()) -> Self {
36        Self::Nil
37    }
38}
39
40impl<'a, T: Text<'a>> From<&'static str> for PrettyTree<'a, T> {
41    fn from(s: &'static str) -> Self {
42        Self::Text(T::from_static_str(s))
43    }
44}
45
46impl<'a, T: Text<'a>> From<T> for PrettyTree<'a, T> {
47    fn from(s: T) -> Self {
48        Self::Text(s)
49    }
50}