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