forked from dbp/sublime-rust
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathsyntax_test_struct.rs
124 lines (112 loc) · 3.92 KB
/
syntax_test_struct.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// SYNTAX TEST "Packages/Rust Enhanced/RustEnhanced.sublime-syntax"
struct BasicStruct(i32);
// ^^^^^^^^^^^^^^^^^^^^ meta.struct
// <- storage.type.struct
//^^^^ storage.type.struct
// ^^^^^^^^^^^ entity.name.struct
// ^ punctuation.section.group.begin
// ^^^ storage.type
// ^ punctuation.section.group.end
struct PrintableStruct(Box<i32>);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.struct
// <- storage.type.struct
//^^^^ storage.type.struct
// ^^^^^^^^^^^^^^^ entity.name.struct
// ^ punctuation.section.group.begin
// ^^^^^^^^ meta.generic
// ^^^ support.type
// ^ punctuation.definition.generic.begin
// ^^^ storage.type
// ^ punctuation.definition.generic.end
// ^ punctuation.section.group.end
struct Nil;
// ^^^^^^^ meta.struct
// ^ - meta.struct
struct Pair(i32, i32);
// ^^^^^^^^^^^^^^^^^^ meta.struct
// ^^^ storage.type
// ^^^ storage.type
// ^ - meta.struct
struct /*comment*/ Comments {}
// ^^^^^^^^^^^ meta.struct comment.block
struct Point
// ^^^^^^^^^ meta.struct
{
// <- meta.struct meta.block punctuation.section.block.begin
x: i32,
// ^ variable.other.member
// ^ punctuation.separator
// ^^^ storage.type
y: i32
// ^ variable.other.member
// ^ punctuation.separator
// ^^^ storage.type
}
// <- meta.block punctuation.section.block.end
impl Point
//^^^^^^^^ meta.impl
{
// <- meta.impl meta.block punctuation.section.block.begin
fn new(x: i32, y: i32) -> Point
// <- storage.type.function
// ^^^ entity.name.function
{
// <- meta.function meta.block
Point {x: x, y: y}
}
fn double(&mut self) {
// ^^^^^^ entity.name.function
self.x *= 2;
// ^^^^ variable.language
// ^ punctuation.accessor.dot
// ^^ keyword.operator.assignment
self.y *= 2;
}
}
// TODO: `meta.group` should cover the closing parenthesis.
struct Val (f64,);
//^^^^^^^^^^^^^^^ meta.struct
// ^^^ entity.name.struct
// ^^^^^ meta.group
// ^ punctuation.section.group.begin
// ^^^ storage.type
// ^ punctuation.section.group.end
// ^ punctuation.terminator
struct F {
f: extern "C" fn(x: u8, ... /* comment */),
// ^^^^^^ meta.struct meta.block keyword.other
// ^^^ meta.struct meta.block string.quoted.double
// ^^ meta.struct meta.block storage.type.function
// ^^^^^^^^^^^^^ meta.struct meta.block meta.group comment.block
g: extern "C" fn(x: u8, /* comment */ ...),
// ^^^^^^^^^^^^^ meta.struct meta.block meta.group comment.block
h: extern "C" fn(x: u8, ...),
i: extern "C" fn(
x: u8,
// ^^ meta.struct meta.block meta.group storage.type
// comment 4
// ^^^^^^^^^^^^^ meta.struct meta.block meta.group comment.line.double-slash
y: String, // comment 3
// ^^^^^^^^^^^^^ meta.struct meta.block meta.group comment.line.double-slash
z: Foo,
),
}
let mut j = BasicStruct(10);
// ^^^ storage.modifier
// ^^ constant.numeric.integer.decimal
let p = Point {x: 10.0, y: 20.0};
// ^^^^^ storage.type.source
// ^^^^^^^^^^^^^^^^^^ meta.block
// ^ punctuation.section.block.begin
// ^ punctuation.separator
// ^^^^ constant.numeric.float
// ^ punctuation.section.block.end
let n = NothingInMe {};
// ^^^^^^^^^^^ storage.type.source
// ^^ meta.block
let tp = TuplePoint { 0: 10.0, 1: 20.0 };
// ^constant.numeric.integer.decimal
// ^ constant.numeric.integer.decimal
let p = Point { x, y };
// ^^^^^ storage.type.source
// ^^^^^^^^ meta.block