• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![feature(specialization)]
2 
3 // Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
4 
5 pub trait Go {
go(&self, arg: isize)6     fn go(&self, arg: isize);
7 }
8 
go<G:Go>(this: &G, arg: isize)9 pub fn go<G:Go>(this: &G, arg: isize) {
10     this.go(arg)
11 }
12 
13 pub trait GoMut {
go_mut(&mut self, arg: isize)14     fn go_mut(&mut self, arg: isize);
15 }
16 
go_mut<G:GoMut>(this: &mut G, arg: isize)17 pub fn go_mut<G:GoMut>(this: &mut G, arg: isize) {
18     this.go_mut(arg)
19 }
20 
21 pub trait GoOnce {
go_once(self, arg: isize)22     fn go_once(self, arg: isize);
23 }
24 
go_once<G:GoOnce>(this: G, arg: isize)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 {
go_mut(&mut self, arg: isize)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 {
go_once(mut self, arg: isize)40     default fn go_once(mut self, arg: isize) {
41         go_mut(&mut self, arg)
42     }
43 }
44