forked from yewstack/yew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml-component-fail.rs
96 lines (82 loc) · 3.06 KB
/
html-component-fail.rs
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
87
88
89
90
91
92
93
94
95
96
#![recursion_limit = "128"]
use std::marker::PhantomData;
use yew::prelude::*;
#[derive(Clone, Properties, PartialEq)]
pub struct ChildProperties {
pub string: String,
#[props(required)]
pub int: i32,
}
pub struct Child;
impl Component for Child {
type Message = ();
type Properties = ChildProperties;
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { unimplemented!() }
fn update(&mut self, _: Self::Message) -> ShouldRender { unimplemented!() }
fn view(&self) -> Html { unimplemented!() }
}
#[derive(Clone, Properties)]
pub struct ChildContainerProperties {
#[props(required)]
pub children: ChildrenWithProps<Child>,
}
pub struct ChildContainer;
impl Component for ChildContainer {
type Message = ();
type Properties = ChildContainerProperties;
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { unimplemented!() }
fn update(&mut self, _: Self::Message) -> ShouldRender { unimplemented!() }
fn view(&self) -> Html { unimplemented!() }
}
pub struct Generic<G> {
marker: PhantomData<G>,
}
impl Component for Generic<String> {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { unimplemented!() }
fn update(&mut self, _: Self::Message) -> ShouldRender { unimplemented!() }
fn view(&self) -> Html { unimplemented!() }
}
fn compile_fail() {
html! { <Child> };
html! { <Child:: /> };
html! { <Child with /> };
html! { <Child props /> };
html! { <Child with props > };
html! { <Child with props ref=() ref=() /> };
html! { <Child with props ref=() ref=() value=1 /> };
html! { <Child with props ref=() value=1 ref=() /> };
html! { <Child with props value=1 ref=() ref=() /> };
html! { <Child value=1 with props ref=() ref=() /> };
html! { <Child value=1 ref=() with props ref=() /> };
html! { <Child ref=() ref=() value=1 with props /> };
html! { <Child ref=() with props /> };
html! { <Child with blah /> };
html! { <Child with props () /> };
html! { <Child value=1 with props /> };
html! { <Child with props value=1 /> };
html! { <Child type=0 /> };
html! { <Child invalid-prop-name=0 /> };
html! { <Child unknown="unknown" /> };
html! { <Child string= /> };
html! { <Child int=1 string={} /> };
html! { <Child int=1 string=3 /> };
html! { <Child int=1 string={3} /> };
html! { <Child int=1 ref=() /> };
html! { <Child int=1 ref=() ref=() /> };
html! { <Child int=0u32 /> };
html! { <Child string="abc" /> };
html! { </Child> };
html! { <Child><Child></Child> };
html! { <Child></Child><Child></Child> };
html! { <Child>{ "Not allowed" }</Child> };
html! { <ChildContainer /> };
html! { <ChildContainer></ChildContainer> };
html! { <ChildContainer>{ "Not allowed" }</ChildContainer> };
html! { <ChildContainer><></></ChildContainer> };
html! { <ChildContainer><other /></ChildContainer> };
html! { <Generic<String>></Generic> };
html! { <Generic<String>></Generic<Vec<String>>> };
}
fn main() {}