Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions RustEnhanced.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ contexts:
1: storage.modifier.rust
2: storage.type.type.rust
3: entity.name.type.rust
push:
- match: '=(?!=)'
scope: keyword.operator.rust
push: after-operator
- match: '(?=\S)'
pop: true

- match: '\b(?:(pub)\s+)?(trait)\s+({{identifier}})\b'
captures:
Expand Down Expand Up @@ -129,7 +135,6 @@ contexts:

- match: \breturn\b
scope: keyword.control.rust
push: after-operator

- match: \b(as|in|box)\b
scope: keyword.operator.rust
Expand Down Expand Up @@ -213,18 +218,14 @@ contexts:
# match blocks containing just enums
- match: '=>'
scope: keyword.operator.rust
push: after-operator

- match: '=(?!=)'
scope: keyword.operator.rust
push: after-operator

- match: '[;,]'
push: after-operator

- match: ':'
scope: punctuation.separator.rust
push: after-operator

- match: '\.\.\.'
scope: keyword.operator.rust
Expand Down Expand Up @@ -446,6 +447,7 @@ contexts:
pop: true

type-any-identifier:
- include: comments
- include: support-type
- include: return-type
- match: '&'
Expand Down
37 changes: 36 additions & 1 deletion syntax_test_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,4 +1097,39 @@ where
T: AsRef<str>;
//^^^^^^^^^^^^^^^ meta.struct
// ^^^ meta.struct meta.where storage.type
// ^ punctuation.terminator
// ^ punctuation.terminator

fn foo<F: FnMut(i32, i32 /*asd*/) -> i32>(f: F) {
// ^^^^^^^ meta.generic comment
let lam = |time: i32 /* comment */, other: i32| {
// ^^^^^^^^^^^^^ meta.function.parameters comment
};
}

// mdo example
fn main() {
// exporting the monadic functions for the Iterator monad (similar
// to list comprehension)
use mdo::iter::{bind, ret, mzero};

let l = bind(1i32..11, move |z|
bind(1..z, move |x|
bind(x..z, move |y|
bind(if x * x + y * y == z * z { ret(()) }
else { mzero() },
move |_|
ret((x, y, z))
)))).collect::<Vec<_>>();
println!("{:?}", l);

// the same thing, using the mdo! macro
let l = mdo! {
z =<< 1i32..11;
x =<< 1..z;
// ^^^ keyword.operator
y =<< x..z;
when x * x + y * y == z * z;
ret ret((x, y, z))
}.collect::<Vec<_>>();
println!("{:?}", l);
}