1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use dyn_clonable::clonable;
use std::fmt;
pub trait AsFooter {
fn as_footer(&self) -> Box<dyn MarkdownElement>;
}
#[clonable]
pub trait MarkdownElement: Clone + fmt::Debug {
fn render(&self) -> String;
}
impl<T> MarkdownElement for T
where
T: Clone + fmt::Debug + fmt::Display,
{
fn render(&self) -> String {
format!("{}", self)
}
}
impl<'a, T: 'a> From<T> for Box<dyn MarkdownElement + 'a>
where
T: Clone + fmt::Debug + fmt::Display,
{
fn from(value: T) -> Self {
Box::new(value)
}
}