Skip to content

Commit

Permalink
Rust: Improved punctuation and operators (#1839)
Browse files Browse the repository at this point in the history
This improves Rust's existing punctuation and operators, adds support for new ones, and updates the tests.
  • Loading branch information
RunDevelopment authored Apr 7, 2019
1 parent e268395 commit a42b155
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/prism-rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ Prism.languages.rust = {
'operator': /[&*]/
}
},
'punctuation': /[{}[\];(),:]|\.+|->/,
'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
};
'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
};
2 changes: 1 addition & 1 deletion components/prism-rust.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/languages/rust/operator_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| || |=
< << <= <<=
> >> >= >>=
@
@ ?

----------------------------------------------------

Expand All @@ -27,9 +27,9 @@
["operator", "|"], ["operator", "||"], ["operator", "|="],
["operator", "<"], ["operator", "<<"], ["operator", "<="], ["operator", "<<="],
["operator", ">"], ["operator", ">>"], ["operator", ">="], ["operator", ">>="],
["operator", "@"]
["operator", "@"], ["operator", "?"]
]

----------------------------------------------------

Checks for all operators.
Checks for all operators.
29 changes: 29 additions & 0 deletions tests/languages/rust/punctuation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
->
. .. ... ..=
::
{} [] ()
; , :

----------------------------------------------------

[
["punctuation", "->"],
["punctuation", "."],
["punctuation", ".."],
["punctuation", "..."],
["punctuation", "..="],
["punctuation", "::"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", "["],
["punctuation", "]"],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],
["punctuation", ","],
["punctuation", ":"]
]

----------------------------------------------------

Checks for all punctuation.

0 comments on commit a42b155

Please sign in to comment.