]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/auxiliary/go_trait.rs
Rollup merge of #106714 - Ezrashaw:remove-e0490, r=davidtwco
[rust.git] / tests / ui / traits / auxiliary / go_trait.rs
1 #![feature(specialization)]
2
3 // Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
4
5 pub trait Go {
6     fn go(&self, arg: isize);
7 }
8
9 pub fn go<G:Go>(this: &G, arg: isize) {
10     this.go(arg)
11 }
12
13 pub trait GoMut {
14     fn go_mut(&mut self, arg: isize);
15 }
16
17 pub fn go_mut<G:GoMut>(this: &mut G, arg: isize) {
18     this.go_mut(arg)
19 }
20
21 pub trait GoOnce {
22     fn go_once(self, arg: isize);
23 }
24
25 pub fn go_once<G:GoOnce>(this: G, arg: isize) {
26     this.go_once(arg)
27 }
28
29 impl<G> GoMut for G
30     where G : Go
31 {
32     default fn go_mut(&mut self, arg: isize) {
33         go(&*self, arg)
34     }
35 }
36
37 impl<G> GoOnce for G
38     where G : GoMut
39 {
40     default fn go_once(mut self, arg: isize) {
41         go_mut(&mut self, arg)
42     }
43 }