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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
pub trait PropsBuilder<T> {
fn build(self) -> T;
}
pub trait Props {
type InitialBuilder;
fn init_builder() -> Self::InitialBuilder;
}
pub struct NoProps;
impl PropsBuilder<NoProps> for NoProps {
#[inline]
fn build(self) -> NoProps {
self
}
}
impl Props for NoProps {
type InitialBuilder = NoProps;
#[inline]
fn init_builder() -> Self::InitialBuilder {
NoProps
}
}
pub trait UseRender {
type RenderArg: Props;
type RenderOutput;
fn use_render(&self, props: &Self::RenderArg) -> Self::RenderOutput;
}
pub trait Component {
type Props: Props;
type Element;
fn create_element(self, props: Self::Props, key: Option<crate::Key>) -> Self::Element;
}
pub trait UseRenderStatic {
type RenderArg: Props;
type RenderOutput;
fn use_render(props: &Self::RenderArg) -> Self::RenderOutput;
}
pub trait ComponentStatic {
type Props: Props;
type Element;
fn create_element(props: Self::Props, key: Option<crate::Key>) -> Self::Element;
}
impl<T: UseRenderStatic> UseRender for T {
type RenderArg = <T as UseRenderStatic>::RenderArg;
type RenderOutput = <T as UseRenderStatic>::RenderOutput;
#[inline]
fn use_render(&self, props: &Self::RenderArg) -> Self::RenderOutput {
T::use_render(props)
}
}
impl<T: ComponentStatic> Component for T {
type Props = <T as ComponentStatic>::Props;
type Element = <T as ComponentStatic>::Element;
#[inline]
fn create_element(self, props: Self::Props, key: Option<crate::Key>) -> Self::Element {
T::create_element(props, key)
}
}