]> git.lizzy.rs Git - rust.git/blob - tests/source/trait.rs
Merge pull request #866 from rust-lang-nursery/empty-extern
[rust.git] / tests / source / trait.rs
1 // Test traits
2
3 trait Foo {
4     fn bar(x: i32   ) -> Baz<   U> {       Baz::new()
5   }
6
7     fn baz(a: AAAAAAAAAAAAAAAAAAAAAA,
8 b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
9 -> RetType;
10
11     fn foo(a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Another comment
12 b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
13            -> RetType              ; // Some comment
14
15     fn baz(&mut self        ) -> i32          ;
16
17 fn increment(&     mut self, x: i32         );
18
19     fn read(&mut self,          x: BufReader<R> /* Used to be MemReader */)
20     where R: Read;
21 }
22
23 pub trait WriteMessage {
24     fn write_message  (&mut self, &FrontendMessage) ->   io::Result<()>;
25 }
26
27 trait Runnable {
28     fn handler(self: & Runnable   );
29 }
30
31 trait TraitWithExpr {
32     fn fn_with_expr(x: [i32;       1]);
33 }
34
35 trait Test {
36     fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) -> Result<T, Self::Error> where F: FnOnce(&mut Self) -> Result<T, Self::Error>;
37 }
38
39 trait T<> {}
40
41 trait Foo { type Bar: Baz;}
42
43 trait ConstCheck<T>:Foo   where   T: Baz { 
44         const   J:   i32;
45 }
46
47 trait Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T> 
48     where T: Foo {}
49
50 trait Ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T> where T: Foo {}
51
52 trait FooBar<T> : Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt where J: Bar { fn test(); }
53
54 trait WhereList<T, J> where T: Foo, J: Bar {}
55