]> git.lizzy.rs Git - rust.git/blob - tests/target/multiple.rs
Support single-line functions
[rust.git] / tests / target / multiple.rs
1 // rustfmt-wrap_comments: true
2 // Test of lots of random stuff.
3 // FIXME split this into multiple, self-contained tests.
4
5
6 #[attr1]
7 extern crate foo;
8 #[attr2]
9 #[attr3]
10 extern crate foo;
11 #[attr1]
12 extern crate foo;
13 #[attr2]
14 #[attr3]
15 extern crate foo;
16
17 use std::cell::*;
18 use std::{self, any, ascii, borrow, boxed, char, borrow, boxed, char, borrow, borrow, boxed, char,
19           borrow, boxed, char, borrow, boxed, char, borrow, boxed, char, borrow, boxed, char,
20           borrow, boxed, char, borrow, boxed, char, borrow, boxed, char};
21
22 mod doc;
23 mod other;
24
25
26 // sfdgfffffffffffffffffffffffffffffffffffffffffffffffffffffff
27 // ffffffffffffffffffffffffffffffffffffffffff
28
29 fn foo(a: isize, b: u32 /* blah blah */, c: f64) { }
30
31 fn foo() -> Box<Write + 'static>
32     where 'a: 'b,
33           for<'a> D<'b>: 'a
34 {
35     hello!()
36 }
37
38 fn baz<'a: 'b, // comment on 'a
39        T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType /* comment on T */>
40     (a: A,
41      b: B, // comment on b
42      c: C)
43      -> Bob {
44     #[attr1]
45     extern crate foo;
46     #[attr2]
47     #[attr3]
48     extern crate foo;
49     #[attr1]
50     extern crate foo;
51     #[attr2]
52     #[attr3]
53     extern crate foo;
54 }
55
56 #[rustfmt_skip]
57 fn qux(a: dadsfa,   // Comment 1
58        b: sdfasdfa, // Comment 2
59        c: dsfdsafa) // Comment 3
60 {
61
62 }
63
64 /// Blah blah blah.
65 impl Bar {
66     fn foo(&mut self,
67            a: sdfsdfcccccccccccccccccccccccccccccccccccccccccccccccccc, // comment on a
68            b: sdfasdfsdfasfs /* closing comment */)
69            -> isize {
70     }
71
72     /// Blah blah blah.
73     pub fn f2(self) {
74         (foo, bar)
75     }
76
77     #[an_attribute]
78     fn f3(self) -> Dog { }
79 }
80
81 /// The `nodes` and `edges` method each return instantiations of
82 /// `Cow<[T]>` to leave implementers the freedom to create
83
84 /// entirely new vectors or to pass back slices into internally owned
85 /// vectors.
86 pub trait GraphWalk<'a, N, E> {
87     /// Returns all the nodes in this graph.
88     fn nodes(&'a self) -> Nodes<'a, N>;
89     /// Returns all of the edges in this graph.
90     fn edges(&'a self) -> Edges<'a, E>;
91     /// The source node for `edge`.
92     fn source(&'a self, edge: &E) -> N;
93     /// The target node for `edge`.
94     fn target(&'a self, edge: &E) -> N;
95 }
96
97 /// A Doc comment
98 #[AnAttribute]
99 pub struct Foo {
100     #[rustfmt_skip]
101     f :   SomeType, // Comment beside a field
102     f: SomeType, // Comment beside a field
103     // Comment on a field
104     g: SomeOtherType,
105     /// A doc comment on a field
106     h: AThirdType,
107 }
108
109 struct Bar;
110
111 // With a where clause and generics.
112 pub struct Foo<'a, Y: Baz>
113     where X: Whatever
114 {
115     f: SomeType, // Comment beside a field
116 }
117
118 fn foo(ann: &'a (PpAnn + 'a)) { }
119
120 fn main() {
121     for i in 0i32..4 {
122         println!("{}", i);
123     }
124
125
126     while true {
127         hello();
128     }
129
130     let rc = Cell::new(42usize,
131                        42usize,
132                        Cell::new(42usize,
133                                  remaining_widthremaining_widthremaining_widthremaining_width),
134                        42usize);
135     let rc = RefCell::new(42usize, remaining_width, remaining_width);  // a comment
136     let x = "Hello!!!!!!!!! abcd  abcd abcd abcd abcd abcd\n abcd abcd abcd abcd abcd abcd abcd \
137              abcd abcd abcd  abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd \
138              abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd \
139              abcd abcd";
140     let s = expand(a, b);
141 }
142
143 fn deconstruct()
144     -> (SocketAddr,
145         Method,
146         Headers,
147         RequestUri,
148         HttpVersion,
149         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
150 {
151 }
152
153 fn deconstruct(foo: Bar)
154                -> (SocketAddr,
155                    Method,
156                    Headers,
157                    RequestUri,
158                    HttpVersion,
159                    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) {
160 }