forked from yewstack/yew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generic-component-fail.rs
54 lines (44 loc) · 1.08 KB
/
generic-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
use std::marker::PhantomData;
use yew::prelude::*;
pub struct Generic<T> {
marker: PhantomData<T>,
}
impl<T> Component for Generic<T>
where
T: 'static,
{
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
unimplemented!()
}
fn view(&self, _ctx: &Context<Self>) -> Html {
unimplemented!()
}
}
pub struct Generic2<T1, T2> {
marker: PhantomData<(T1, T2)>,
}
impl<T1, T2> Component for Generic2<T1, T2>
where
T1: 'static,
T2: 'static,
{
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
unimplemented!()
}
fn view(&self, _ctx: &Context<Self>) -> Html {
unimplemented!()
}}
fn compile_fail() {
#[allow(unused_imports)]
use std::path::Path;
html! { <Generic<String>> };
html! { <Generic<String>></Generic> };
html! { <Generic<String>></Generic<Vec<String>>> };
html! { <Generic<String>></Generic<Path>> };
html! { <Generic<String>></> };
}
fn main() {}