]> git.lizzy.rs Git - rust.git/blob - tests/target/enum.rs
Merge pull request #1639 from topecongiro/rfc-update
[rust.git] / tests / target / enum.rs
1 // rustfmt-wrap_comments: true
2 // rustfmt-error_on_line_overflow: false
3 // Enums test
4
5 #[atrr]
6 pub enum Test {
7     A,
8     B(u32, A /* comment */, SomeType),
9     /// Doc comment
10     C,
11 }
12
13 pub enum Foo<'a, Y: Baz>
14     where X: Whatever
15 {
16     A,
17 }
18
19 enum EmtpyWithComment {
20     // Some comment
21 }
22
23 // C-style enum
24 enum Bar {
25     A = 1,
26     #[someAttr(test)]
27     B = 2, // comment
28     C,
29 }
30
31 enum LongVariants {
32     First(LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment
33           VARIANT),
34     // This is the second variant
35     Second,
36 }
37
38 enum StructLikeVariants {
39     Normal(u32, String),
40     StructLike {
41         x: i32, // Test comment
42         // Pre-comment
43         #[Attr50]
44         y: SomeType, // Aanother Comment
45     },
46     SL { a: A },
47 }
48
49 enum X {
50     CreateWebGLPaintTask(Size2D<i32>,
51                          GLContextAttributes,
52                          IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>), /* This is a post comment */
53 }
54
55 pub enum EnumWithAttributes {
56     // This is a pre comment
57     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
58     TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
59                                     * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
60     // Pre Comment
61     #[rustfmt_skip]
62     SkippedItem(String,String,), // Post-comment
63     #[another_attr]
64     #[attr2]
65     ItemStruct { x: usize, y: usize }, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
66     // And another
67     ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
68                       * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
69 }
70
71 pub enum SingleTuple {
72     // Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
73     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
74     Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
75 }
76
77 pub enum SingleStruct {
78     Match { name: String, loc: usize }, // Post-comment
79 }
80
81 pub enum GenericEnum<I, T>
82     where I: Iterator<Item = T>
83 {
84     // Pre Comment
85     Left { list: I, root: T }, // Post-comment
86     Right { list: I, root: T }, // Post Comment
87 }
88
89
90 enum EmtpyWithComment {
91     // Some comment
92 }
93
94 enum TestFormatFails {
95     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
96 }
97
98 fn nested_enum_test() {
99     if true {
100         enum TestEnum {
101             One(usize,
102                 usize,
103                 usize,
104                 usize,
105                 usize,
106                 usize,
107                 usize,
108                 usize,
109                 usize,
110                 usize,
111                 usize,
112                 usize,
113                 usize,
114                 usize,
115                 usize,
116                 usize), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
117                          * AAAAAAAAAAAAAAAAAAAAAA */
118             Two, /* AAAAAAAAAAAAAAAAAA  AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
119                   * AAAAAAAAAAAAAAAAAA */
120         }
121         enum TestNestedFormatFail {
122             AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
123         }
124     }
125 }
126
127 pub struct EmtpyWithComment {
128     // FIXME: Implement this struct
129 }
130
131 // #1115
132 pub enum Bencoding<'i> {
133     Str(&'i [u8]),
134     Int(i64),
135     List(Vec<Bencoding<'i>>),
136     /// A bencoded dict value. The first element the slice of bytes in the
137     /// source that the dict is
138     /// composed of. The second is the dict, decoded into an ordered map.
139     // TODO make Dict "structlike" AKA name the two values.
140     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
141 }
142
143 // #1261
144 pub enum CoreResourceMsg {
145     SetCookieForUrl(ServoUrl,
146                     #[serde(deserialize_with = "::hyper_serde::deserialize",
147                             serialize_with = "::hyper_serde::serialize")]
148                     Cookie,
149                     CookieSource),
150 }