Skip to content

Commit a42b155

Browse files
Rust: Improved punctuation and operators (#1839)
This improves Rust's existing punctuation and operators, adds support for new ones, and updates the tests.
1 parent e268395 commit a42b155

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

components/prism-rust.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ Prism.languages.rust = {
6363
'operator': /[&*]/
6464
}
6565
},
66-
'punctuation': /[{}[\];(),:]|\.+|->/,
67-
'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
68-
};
66+
'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
67+
'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
68+
};

components/prism-rust.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/rust/operator_feature.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
| || |=
1111
< << <= <<=
1212
> >> >= >>=
13-
@
13+
@ ?
1414

1515
----------------------------------------------------
1616

@@ -27,9 +27,9 @@
2727
["operator", "|"], ["operator", "||"], ["operator", "|="],
2828
["operator", "<"], ["operator", "<<"], ["operator", "<="], ["operator", "<<="],
2929
["operator", ">"], ["operator", ">>"], ["operator", ">="], ["operator", ">>="],
30-
["operator", "@"]
30+
["operator", "@"], ["operator", "?"]
3131
]
3232

3333
----------------------------------------------------
3434

35-
Checks for all operators.
35+
Checks for all operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
->
2+
. .. ... ..=
3+
::
4+
{} [] ()
5+
; , :
6+
7+
----------------------------------------------------
8+
9+
[
10+
["punctuation", "->"],
11+
["punctuation", "."],
12+
["punctuation", ".."],
13+
["punctuation", "..."],
14+
["punctuation", "..="],
15+
["punctuation", "::"],
16+
["punctuation", "{"],
17+
["punctuation", "}"],
18+
["punctuation", "["],
19+
["punctuation", "]"],
20+
["punctuation", "("],
21+
["punctuation", ")"],
22+
["punctuation", ";"],
23+
["punctuation", ","],
24+
["punctuation", ":"]
25+
]
26+
27+
----------------------------------------------------
28+
29+
Checks for all punctuation.

0 commit comments

Comments
 (0)