]>
Commit | Line | Data |
---|---|---|
54a0048b SL |
1 | #![feature(specialization)] |
2 | ||
3 | // First, test only use of explicit `default` items: | |
4 | ||
5 | pub trait Foo { | |
6 | fn foo(&self) -> bool; | |
7 | } | |
8 | ||
9 | impl<T> Foo for T { | |
10 | default fn foo(&self) -> bool { false } | |
11 | } | |
12 | ||
13 | impl Foo for i32 {} | |
14 | ||
15 | impl Foo for i64 { | |
16 | fn foo(&self) -> bool { true } | |
17 | } | |
18 | ||
19 | // Next, test mixture of explicit `default` and provided methods: | |
20 | ||
21 | pub trait Bar { | |
22 | fn bar(&self) -> i32 { 0 } | |
23 | } | |
24 | ||
e74abb32 XL |
25 | impl<T> Bar for T { |
26 | default fn bar(&self) -> i32 { 0 } | |
27 | } | |
54a0048b SL |
28 | |
29 | impl Bar for i32 { | |
30 | fn bar(&self) -> i32 { 1 } | |
31 | } | |
32 | impl<'a> Bar for &'a str {} | |
33 | ||
34 | impl<T> Bar for Vec<T> { | |
35 | default fn bar(&self) -> i32 { 2 } | |
36 | } | |
37 | impl Bar for Vec<i32> {} | |
38 | impl Bar for Vec<i64> { | |
39 | fn bar(&self) -> i32 { 3 } | |
40 | } |