blob: 8caa8524fb99620c0a50381e633cd3cbc8245b60 (
plain)
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
|
#![feature(specialization)]
pub trait Foo {
fn foo(&self) -> &'static str;
}
impl<T> Foo for T {
default fn foo(&self) -> &'static str {
"generic"
}
}
impl<T: Clone> Foo for T {
default fn foo(&self) -> &'static str {
"generic Clone"
}
}
impl<T, U> Foo for (T, U) where T: Clone, U: Clone {
default fn foo(&self) -> &'static str {
"generic pair"
}
}
impl<T: Clone> Foo for (T, T) {
default fn foo(&self) -> &'static str {
"generic uniform pair"
}
}
impl Foo for (u8, u32) {
default fn foo(&self) -> &'static str {
"(u8, u32)"
}
}
impl Foo for (u8, u8) {
default fn foo(&self) -> &'static str {
"(u8, u8)"
}
}
impl<T: Clone> Foo for Vec<T> {
default fn foo(&self) -> &'static str {
"generic Vec"
}
}
impl Foo for Vec<i32> {
fn foo(&self) -> &'static str {
"Vec<i32>"
}
}
impl Foo for String {
fn foo(&self) -> &'static str {
"String"
}
}
impl Foo for i32 {
fn foo(&self) -> &'static str {
"i32"
}
}
pub trait MyMarker {}
impl<T: Clone + MyMarker> Foo for T {
default fn foo(&self) -> &'static str {
"generic Clone + MyMarker"
}
}
|