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