]> git.lizzy.rs Git - rust.git/blob - tests/source/structs.rs
bd9db77fec0ba7a5c5fdda891f1447aa090fcb61
[rust.git] / tests / source / 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
21 NewInt     <T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */
22
23
24     );
25
26 struct Qux<'a,
27            N: Clone + 'a,
28            E: Clone + 'a,
29            G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
30            W: Write + Copy>
31 (
32     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
33     BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
34     #[AnAttr]    
35     // Comment
36     /// Testdoc
37     G,
38     pub W,
39 );
40
41 struct Tuple(/*Comment 1*/ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
42              /* Comment 2   */ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,);
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
53     a: A,  // Comment A
54     b: B, // Comment B
55     c: C,   // Comment C
56
57 }
58
59 struct Baz {
60     a: A,  // Comment A
61
62     b: B, // Comment B
63
64
65
66
67     c: C,   // Comment C
68 }
69
70 struct Baz {
71
72     a: A,
73
74     b: B,
75     c: C,
76
77
78
79     
80     d: D
81
82 }
83
84 struct Baz
85 {
86     // Comment A
87     a: A,
88     
89     // Comment B
90 b: B,
91     // Comment C
92       c: C,}
93
94 // Will this be a one-liner?
95 struct Tuple(
96     A, //Comment
97     B
98 );
99
100 pub struct State<F: FnMut() -> time::Timespec> { now: F }
101
102 pub struct State<F: FnMut() -> ()> { now: F }
103
104 pub struct State<F: FnMut()> { now: F }
105
106 struct Palette { /// A map of indizes in the palette to a count of pixels in approximately that color
107                     foo: i32}