]> git.lizzy.rs Git - rust.git/blob - tests/target/structs.rs
Merge pull request #245 from nrc/bugs
[rust.git] / tests / target / structs.rs
1
2 /// A Doc comment
3 #[AnAttribute]
4 pub struct Foo {
5     #[rustfmt_skip]
6     f :   SomeType, // Comment beside a field
7     f: SomeType, // Comment beside a field
8     // Comment on a field
9     #[AnAttribute]
10     g: SomeOtherType,
11     /// A doc comment on a field
12     h: AThirdType,
13     pub i: TypeForPublicField,
14 }
15
16 struct Bar;
17
18 struct NewType(Type, OtherType);
19
20 struct NewInt<T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */);
21
22 struct Qux<'a,
23            N: Clone + 'a,
24            E: Clone + 'a,
25            G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
26            W: Write + Copy>
27 (
28     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
29     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
30     #[AnAttr]
31     // Comment
32     /// Testdoc
33     G,
34     pub W,
35 );
36
37 struct Tuple(
38     // Comment 1
39     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
40     // Comment 2
41     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
42 );
43
44 // With a where clause and generics.
45 pub struct Foo<'a, Y: Baz>
46     where X: Whatever
47 {
48     f: SomeType, // Comment beside a field
49 }
50
51 struct Baz {
52     a: A, // Comment A
53     b: B, // Comment B
54     c: C, // Comment C
55 }
56
57 struct Baz {
58     a: A, // Comment A
59
60     b: B, // Comment B
61
62     c: C, // Comment C
63 }
64
65 struct Baz {
66     a: A,
67
68     b: B,
69     c: C,
70
71     d: D,
72 }
73
74 struct Baz {
75     // Comment A
76     a: A,
77
78     // Comment B
79     b: B,
80     // Comment C
81     c: C,
82 }
83
84 // Will this be a one-liner?
85 struct Tuple(A /* Comment */, B);
86
87 pub struct State<F: FnMut() -> time::Timespec> {
88     now: F,
89 }
90
91 pub struct State<F: FnMut() -> ()> {
92     now: F,
93 }
94
95 pub struct State<F: FnMut()> {
96     now: F,
97 }